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

Re: What's wrong with this expression?



Mikael Magnusson wrote:
On 17 October 2011 23:31, Daniel Serodio (lists)
<daniel.lists@xxxxxxxxxxxxx>  wrote:
Mikael Magnusson wrote:

On 17 October 2011 23:27, Daniel Serodio (lists)
<daniel.lists@xxxxxxxxxxxxx>  wrote:

Mikael Magnusson wrote:

On 17 October 2011 23:09, Daniel Serodio (lists)
<daniel.lists@xxxxxxxxxxxxx>  wrote:

I'm trying to troubleshoot a script that works with bash but fails with zsh,
and it uses the "regex match" operator. What's wrong with this expression?

    [[ "foo" ~= "x" ]]&&  echo true

Fails with "zsh: condition expected: ~="

You wrote ~= instead of =~

Ooops. Error copy'n'pasting. The actual line in the script that fails is:

     if [[ ! "${PATH}" =~ $regex ]] ; then

where "regexp" is:

      regex="^([^:]*:)*${rvm_bin_path}(:[^:]*)*$"

Fails how?

Sorry. Fails with "condition expected: =~"

Maybe you don't have any regex module installed/loaded, does
-regex-match instead of =~ work?
Hmmm, this seems to be the problem.

    [[ "foo" -regex-match "x" ]] && echo x

fails with:

    zsh: unrecognized condition: `foo'




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