Skip to content

Instantly share code, notes, and snippets.

@ELLIOTTCABLE
Created February 10, 2015 15:55
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