Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: What's wrong with this expression?

On 2011-10-18 at 11:08 -0200, Daniel Serodio (lists) wrote:
> >> Ooops. Error copy'n'pasting. The actual line in the script that fails is:
> >>
> >>       if [[ ! "${PATH}" =~ $regex ]] ; then

> Thanks a lot. This computer is running zsh 4.2.6, I'll try to have it 
> updated.

4.2.6 does not have the =~ operator.

=~ was added on 2007-05-01, when Peter applied my patch (I'm the one who
made the mistake which led to ! not working right).  The first release
of zsh with this in was 4.3.5, released on or around 2008-02-01.

zsh 4.2.6 was released on or around 2005-12-03.

Try using -pcre-match instead -- zsh has had PCRE regex support for a
long time, it's only the =~ support and the zsh/regex for using the
system POSIX regexp libraries for extended regexps that were new with

For those versions of zsh with =~ support, it does extended regexps by
default, unless you setopt REMATCH_PCRE.  Anything which is a valid
extended regexp pattern is likely to be a valid PCRE regexp (but not
the other way around).  "man pcrepattern" for more details.

if [[ ! "${PATH}" -pcre-match $regex ]]; then
  # ...


Messages sorted by: Reverse Date, Date, Thread, Author