From: Hamilton Turner <hamiltont@gmail.com>
To: zsh-workers@zsh.org
Subject: Possible bug in OR evaluation in zsh 4.3.10
Date: Thu, 5 Jun 2014 02:18:25 -0400 [thread overview]
Message-ID: <CAFow3A-9czw1OU+P1_go_xswFW92DKizv2GnS-OzAhY6FQ-CLQ@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1255 bytes --]
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
next reply other threads:[~2014-06-05 6:18 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-05 6:18 Hamilton Turner [this message]
2014-06-05 10:42 ` Mikael Magnusson
2014-06-06 5:05 ` Hamilton Turner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAFow3A-9czw1OU+P1_go_xswFW92DKizv2GnS-OzAhY6FQ-CLQ@mail.gmail.com \
--to=hamiltont@gmail.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).