bash does not know boolean variables, nor test (this is what gets called when using [ ).
Decision:
if $myVar ; then ... ; fi
because true and false are commands that return 0 or 1 respectively, as expected by if .
Please note that the values ββare "replaced". The command after if should return 0 on success, and 0 means false in most programming languages.
SAFETY WARNING . This works because BASH expands the variable, then tries to execute the result as a command! Make sure that the variable cannot contain malicious code, for example rm -rf /
Aaron Digulla Sep 28 '10 at 8:01 2010-09-28 08:01
source share