coreutils: Connectives for test
1
1 16.3.6 Connectives for ‘test’
1 -----------------------------
1
1 Note it’s preferred to use shell logical primitives rather than these
1 logical connectives internal to ‘test’, because an expression may become
1 ambiguous depending on the expansion of its parameters.
1
1 For example, this becomes ambiguous when ‘$1’ is set to ‘'!'’ and
1 ‘$2’ to the empty string ‘''’:
1
1 test "$1" -a "$2"
1
1 and should be written as:
1
1 test "$1" && test "$2"
1
1 Note the shell logical primitives also benefit from short circuit
1 operation, which can be significant for file attribute tests.
1
1 ‘! EXPR’
1 True if EXPR is false. ‘!’ has lower precedence than all parts of
1 EXPR. Note ‘!’ needs to be specified to the left of a binary
1 expression, I.e., ‘'!' 1 -gt 2’ rather than ‘1 '!' -gt 2’. Also
1 ‘!’ is often a shell special character and is best used quoted.
1
1 ‘EXPR1 -a EXPR2’
1 True if both EXPR1 and EXPR2 are true. ‘-a’ is left associative,
1 and has a higher precedence than ‘-o’.
1
1 ‘EXPR1 -o EXPR2’
1 True if either EXPR1 or EXPR2 is true. ‘-o’ is left associative.
1