bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: =~ behaves differently in bash 3.2 and 3.0


From: Bernd Eggink
Subject: Re: =~ behaves differently in bash 3.2 and 3.0
Date: Fri, 24 Oct 2008 12:03:55 +0200
User-agent: Thunderbird 2.0.0.17 (X11/20080914)

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

[Prev in Thread] Current Thread [Next in Thread]