Clark J. Wang schrieb:
In bash 3.0.14, the condition [[ file.txt =~ .*\\.txt\$ ]] returns TRUE but
in 3.2.39 it returns FALSE. But with the shopt option `compat31' set it also
returns TRUE. Is that reasonable? In the bash manual, `compat31' makes sense
only for quoted patterns. The string .*\\.txt\$ is considered to be quoted?

I guess it doesn't work in 3.2.39 because there are to many backslashes:

  \\. tests for a literal \ followed by any character.
  \$  tests for a literal $ right after txt

So this works as expected:

  [[ file.txt =~ .*\.txt$ ]]    # condition is true

Don't know about 3.0.14, but it looks like it performed expansion on the regexp, while 3.2.39 leaves it unchanged.

Regards,
Bernd

--
Bernd Eggink
http://sudrala.de


Reply via email to