On Mon, Mar 15, 2021 at 01:57:58PM -0700, Linus Torvalds wrote: > > $ [ "!" = ".size" -a "b" = ".LPBX0," ] > > causes > > dash: 6: [: =: unexpected operator > > because for some reason that "-a" ends up (wild handwaving here about > what is going on) re-parsing the first expression, and ignoring the > quoting around "!" when it does so. The quoting on "!" doesn't help I'm afraid. Even though [ is a built-in it is not allowed to look at the quoting because it's supposed to behave in the same way whether you get the builtin [ or the one from /usr/bin. So when it gets the expression the quoting on the "!" has already been removed. IOW this expression is ambiguous and may or may not fail depending on how it's parsed. Note that when you have a simple expression like [ "!" = ".size" ] special rules come into play on how it is parsed: https://pubs.opengroup.org/onlinepubs/009604499/utilities/test.html But this does not apply when you construct more complex ones with -a. There are two ways around this when writing scripts, you either add something to ensure that "!" cannot occur, e.g., [ "X$a" = "X$b" -a ... ] or you break it down into a simpler expression that is guaranteed by POSIX: [ "$a" = "$b" ] && [ ... ] Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt