2 ms·
Depends on what you mean by "works". Yes, all three shells recognize [[ ]] construct, as it was specifically added to SUS (or POSIX?) for implementation-specifi
by dozzie 10y ago
Depends on what you mean by "works". Yes, all three shells recognize [[ ]]
construct, as it was specifically added to SUS (or POSIX?) for
implementation-specific things, but how they interpret it is up to the
specific shell.
Let's take people's favourite =~ operator. In bash, according to
documentation, it uses ERE syntax. In zsh, it is ERE or PCRE, depending on an
option being set. This is a subtle but important difference in how [[ ]]
works. And then again, your environment can change the behaviour of a script
you're running, which is (a) unexpected and (b) undesirable, and the change in
the behaviour can range from "doesn't find thing it should" to "crashes" to
"goes awry in an unexpected way".