Last active
August 29, 2015 14:07
-
-
Save rroemhild/e41a727833f525d24f25 to your computer and use it in GitHub Desktop.
bash is_true function
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
is_true() { | |
local var=${1,,} | |
case $var in | |
yes|y|true|t|on|1) return 0 ;; | |
esac | |
return 1 | |
} | |
is_true "true"; echo $? | |
# 0 | |
is_true "YES" && echo "true" | |
# true | |
is_true "false"; echo $? | |
# 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment