Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: What's wrong with this expression?
- X-seq: zsh-users 16519
- From: Phil Pennock <zsh-workers+phil.pennock@xxxxxxxxxxxx>
- To: "Daniel Serodio (lists)" <daniel.lists@xxxxxxxxxxxxx>
- Subject: Re: What's wrong with this expression?
- Date: Wed, 19 Oct 2011 04:26:00 -0400
- Cc: Mikael Magnusson <mikachu@xxxxxxxxx>, zsh-users@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=spodhuis.org; s=d201107; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date; bh=IphvxJE+A/NsF8xygQkkz6f8QygW+O5ZM1Ui0YGx1HY=; b=lq62TzzXWK80DTHS6KaukduYXLH6w4oon0fNJvbdM76OegsKfrVzBv7XcbYZPBVg2Hc6h5OG9AlvPWJtEkH48YsuEX8RL+0zHy/GAbysc3rOgKqNZICS54pDvgNOkzDxQKG17+x9ilImluvjpIXWDaMTacur/Zn/qqQUrtq7wLE=;
- In-reply-to: <4E9D7A3C.9040605@mandic.com.br>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mail-followup-to: "Daniel Serodio (lists)" <daniel.lists@xxxxxxxxxxxxx>, Mikael Magnusson <mikachu@xxxxxxxxx>, zsh-users@xxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <4E9C9997.3050306@mandic.com.br> <CAHYJk3Qm8NP_ofAA=9FVhjFHTC+Ay4n5SO0X69gzKV94EjsRfw@mail.gmail.com> <4E9C9DB4.50104@mandic.com.br> <20111018041939.GA52377@redoubt.spodhuis.org> <4E9D7A3C.9040605@mandic.com.br>
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
4.3.5.
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
# ...
fi
-Phil
Messages sorted by:
Reverse Date,
Date,
Thread,
Author