Is the bash double bracket conditional expression without operators, specified/documented anywhere?

Viewed 38
1 Answers

They're listed as equivalent in the Conditional Expressions section of the bash man page:

string
-n string
    True if the length of string is non-zero.

This is also implied by the POSIX spec for the test command (which is equivalent to [ ], which the [[ ]] syntax is based on):

In the following list, $1, $2, $3, and $4 represent the arguments presented to test:

0 arguments:
    Exit false (1).
1 argument:
    Exit true (0) if $1 is not null; otherwise, exit false.

Therefore [ ] and [ '' ] exit with false/failure status, but [ something_nonblank ] exits with true/success status.

Related