zsh-workers
 help / color / mirror / code / Atom feed
* Possible bug in OR evaluation in zsh 4.3.10
@ 2014-06-05  6:18 Hamilton Turner
  2014-06-05 10:42 ` Mikael Magnusson
  0 siblings, 1 reply; 3+ messages in thread
From: Hamilton Turner @ 2014-06-05  6:18 UTC (permalink / raw)
  To: zsh-workers

[-- 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Possible bug in OR evaluation in zsh 4.3.10
  2014-06-05  6:18 Possible bug in OR evaluation in zsh 4.3.10 Hamilton Turner
@ 2014-06-05 10:42 ` Mikael Magnusson
  2014-06-06  5:05   ` Hamilton Turner
  0 siblings, 1 reply; 3+ messages in thread
From: Mikael Magnusson @ 2014-06-05 10:42 UTC (permalink / raw)
  To: Hamilton Turner; +Cc: zsh workers

On 5 June 2014 08:18, Hamilton Turner <hamiltont@gmail.com> 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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Possible bug in OR evaluation in zsh 4.3.10
  2014-06-05 10:42 ` Mikael Magnusson
@ 2014-06-06  5:05   ` Hamilton Turner
  0 siblings, 0 replies; 3+ messages in thread
From: Hamilton Turner @ 2014-06-06  5:05 UTC (permalink / raw)
  To: Mikael Magnusson; +Cc: zsh workers

[-- Attachment #1: Type: text/plain, Size: 22 bytes --]

Good to know, thanks!

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-06-06  5:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-05  6:18 Possible bug in OR evaluation in zsh 4.3.10 Hamilton Turner
2014-06-05 10:42 ` Mikael Magnusson
2014-06-06  5:05   ` Hamilton Turner

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).