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

Re: Possible bug in OR evaluation in zsh 4.3.10



On 5 June 2014 08:18, Hamilton Turner <hamiltont@xxxxxxxxx> wrote:
> I'm experiencing this unexpected behavior:
>
> $ if [[ "foo" =~ "^\s*$" ]]; then; echo "Test"; fi
>> $ if [[ "foo" =~ "^\.+$" ]]; then; echo "Test"; fi
>> $ if [[ "foo" =~ "^\.+$" || "foo" =~ "^\s*$" ]]; then; echo "OR test"; fi
>> OR test
>
>
> Now my shell scripting is definitely not superb, but this seems to be
> incorrect - I would expect that
> none of the if conditions trigger an echo. Assuming that my expectation is
> correct, here's what I
> know:
>
> na: zsh 4.2.1 on Solaris 10 (no =~ operator)
> fail: zsh 4.3.10 on CentOS 6
> fail: zsh 4.3.10 on RH 6.3 and 6.5
> ok; 4.3.17 on Solaris 11
> ok: 4.3.17 on Ubuntu 12.04
> ok: zsh 5.0.2 on Ubuntu 14.04
> ok: zsh 5.0.2 on OS X
> ok: zsh 5.0.2 on CentOS 6
>
> (Thanks a ton to boyd from #zsh for help on different systems)

Yes, this is a bug that has been fixed. IIRC, -regex-match always
works correctly, only the =~ operator didn't, if you do need scripts
to run on broken zsh versions.

-- 
Mikael Magnusson



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