That's a special case of the [[ "\\" =~ ["."] ]]
returning true (because bash called regcomp("[\\.]") instead of regcomp("[.]") I had reported some time ago and was then fixed. Here. It's similar: $ bash -c '[[ "\\" =~ [^]"."] ]]' || echo unexpected unexpected $ ltrace -e regcomp bash -c '[[ "\\" =~ [^]"."] ]]' bash->regcomp(0x7ffc146e78c0, "[^]\\.]", 1) = 0 I suspect bash thinks the first "]" closes the bracket expression and thus assumes the "." is outside them so needs to be escaped for the RE engine as it's quoted in the bash RE. -- Stephane