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

Possible bug in OR evaluation in zsh 4.3.10



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)

This looks a lot like a bug to me, however Josip M.
<http://superuser.com/questions/763829/odd-issue-with-or-operator-in-zsh/763834>
pointed
out that the following works
as expected, even on 4.3.10:

if [[ "foo" =~ "^\.+$" ]] || [[ "foo" =~ "^\s*$" ]]; then; echo "OR test";
> fi


Perhaps this is the proper approach - if so it should likely be mentioned
in docs on using OR.
IIRC, 4.3.10 is the latest in the RH repo, so this could be a non-trivial
issue if it's actually a
bug.

Hope this helps,
Hamilton


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