Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Possible bug in OR evaluation in zsh 4.3.10
- X-seq: zsh-workers 32712
- From: Hamilton Turner <hamiltont@xxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Possible bug in OR evaluation in zsh 4.3.10
- Date: Thu, 5 Jun 2014 02:18:25 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=SgOI718bKO1mqN2IY77WV5hflRQybog2A9YfFTR3Bjo=; b=PzLkp0Fp9SFc1JYk2WcX1PmWz0szNa3NE4WatKfTto5eeVH0KeC2G0hHgY42eAfHYY 4WGQbpIxCAwvTCEk61puR4CtMcqx4vrnhv/WItz8bmzN5VYqTs81n5lykQF0p23o1Ye3 WjMw/SzMJR1CX+4iVkva1ucpv7ivaOX67XG2R8grJYX6pAVa59YSNtWqncuOu7+ne8ni +QbnSnjwNFhauB/+3WeTo2ndxSZ0EgKLfKQ8b5ju+fZE3YOGzfyaHx4Rzzp/BFACzBFD 14dkXYg3Bbb/Vv2MTH2sIBeNLqX/riPD/p5vVZtrnOzC6EoYUQwhBIXTKRSNFPPQw9gm Cz8w==
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
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