This question already has an answer here:
- using single or double bracket - bash 3 answers
The zsh man page, in its section on
[), explicitly advises against using it at all, and urges readers to use
[[ whenever possible.
The relevant section states:
The command attempts to implement POSIX and its extensions where these are specified. Unfortunately there are intrinsic ambiguities in the syntax; in particular there is no distinction between test operators and strings that resemble them. The standard attempts to resolve these for small numbers of arguments (up to four); for five or more arguments compatibility cannot be relied on. Users are urged wherever possible to use the '
[[' test syntax which does not have these ambiguities.
I think I've come across similar advice for bash, but as I scan over the bash man page I can't find any "official" recommendation there on which form (
[[) to use. (Maybe I missed it?)
Is there any reason, other than backward compatibility with "older shells", for using
[in a bash script? Or to put it differently, does bash keep
[[for reasons other than backward compatibility?