Although the misuse of && in [ expr ] is common, it's still important to treat [ as a command, and the check for && / || should only happen when the last argument of the last command in the term appears to be ] (technically both quoted and un-quoted; but people that knows quoting also works since it is only an arg doesn't seem likely to make && mistakes.)
The test content is the same as #463.
# [(){ local IFS=' '; echo -n "$*"; } # shellcheck hangs at this funcdef
# bash: disable the [ builtin
enable -d [; echo -e '#!/bin/bash\necho "$@"'>/tmp/[; chmod +x /tmp/[; PATH=/tmp
[ a && echo b # here we also see shellcheck recgonize && like a syntax keyword; another issue.
A quick review on POSIX.1 2013 Volume 3 Shell & Utilities shows that [ is only a special form of the test util, while [[ and ]] may be keywords.
Although the misuse of
&&in[ expr ]is common, it's still important to treat[as a command, and the check for&&/||should only happen when the last argument of the last command in the term appears to be](technically both quoted and un-quoted; but people that knows quoting also works since it is only an arg doesn't seem likely to make&&mistakes.)The test content is the same as #463.
A quick review on POSIX.1 2013 Volume 3 Shell & Utilities shows that
[is only a special form of thetestutil, while[[and]]may be keywords.