How does Bash determine true/false?
For example:
if true; then echo "true!"; else echo "false"; fi if false; then echo "true!"; else echo "false"; fi # is the given file a Perl script? if perl -ne 'exit 0 if /^#!.*perl\b/; exit 1' $1; then echo "yes, $1 is a Perl script" fi
[ "foobar" = "qux" ]; echo $? # A return value of 0 means true, 1 means false. This is false. [ "$foo" ]; echo $? # True if $foo evaluates to the empty string. [ 1 ]; echo $? # True. [ 0 ]; echo $? # True because "0" is a non-empty string. [ false ]; echo $? # True because this is interpreted as the string "false", not a command to be run. [ "" ]; echo $? # False. [ ]; echo $? # False.