linux - Why are both "true" and "false" tests true? -
the words "true" , "false" special words (builtins) bash. if used in if test, act intuitively expected:
$ if true; echo "true"; else echo "false"; fi true $ if false; echo "true"; else echo "false"; fi false however, 2 tests:
$ [[ true ]] && echo "true" || echo "false" true $ [[ false ]] && echo "true" || echo "false" true both result in true. why?
[[ … ]] is, in case, equivalent test, i.e. test true , test false. looking @ manual test(1):
-n stringlength of string nonzero
stringequivalent-n string
true , false both non-empty strings.
Comments
Post a Comment