Last active
December 9, 2016 06:57
-
-
Save colstrom/082d351d53ed984a27ae82cc814a599b to your computer and use it in GitHub Desktop.
status-to-bool.fish: converts exit statuses into boolean values
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name = status-to-bool | |
| author = Chris Olstrom | |
| license = MIT | |
| provides = fish/functions/status-to-bool | |
| requires | |
| fish/builtin/and | |
| fish/builtin/case | |
| fish/builtin/echo | |
| fish/builtin/end | |
| fish/builtin/exit | |
| fish/builtin/false | |
| fish/builtin/function | |
| fish/builtin/return | |
| fish/builtin/set | |
| fish/builtin/switch | |
| fish/builtin/test | |
| fish/builtin/true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function status-to-bool --argument exit | |
| set --local last $status | |
| test -z "$exit" | |
| and set exit $last | |
| switch "$exit" | |
| case 0 | |
| echo true | |
| case '*' | |
| echo false | |
| end | |
| return $exit | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment