Skip to content

Instantly share code, notes, and snippets.

@ELLIOTTCABLE
Created February 10, 2015 15:55
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ELLIOTTCABLE/3a945b04ed8170d710ac to your computer and use it in GitHub Desktop.
Save ELLIOTTCABLE/3a945b04ed8170d710ac to your computer and use it in GitHub Desktop.
POSIX-compatible shell-script truthiness-checking cheat-sheet with-a hyphenated-title
[ -n "${VAR##[NFnf]*}" ] && echo '$VAR must be truthy (but will be considered falsey by default, if empty)'
[ -z "${VAR##[YTyt]*}" ] && echo '$VAR must be truthy (and will be by default, if empty)'
[ -z "${VAR##[NFnf]*}" ] && echo '$VAR must be falsey (and will be by default, if empty)'
[ -n "${VAR##[YTyt]*}" ] && echo '$VAR must be falsey (but will be considered truthy by default, if empty)'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment