Skip to content

Instantly share code, notes, and snippets.

@rroemhild
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rroemhild/e41a727833f525d24f25 to your computer and use it in GitHub Desktop.
Save rroemhild/e41a727833f525d24f25 to your computer and use it in GitHub Desktop.
bash is_true function
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