Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [[ 0 =~ 1 || 1 = 0 ]] returns true
- X-seq: zsh-workers 28386
 
- From: Brandon Philips <brandon@xxxxxxxx>
 
- To: Michael Hwang <michael.a.hwang@xxxxxxxxx>,	Mikael Magnusson <mikachu@xxxxxxxxx>,	zsh workers <zsh-workers@xxxxxxx>
 
- Subject: Re: [[ 0 =~ 1 || 1 = 0 ]] returns true
 
- Date: Tue, 2 Nov 2010 09:34:28 -0700
 
- In-reply-to: <20101009221700.GA60765@xxxxxxxxxxxxxxxxxxxx>
 
- 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
 
- References: <AANLkTi=G-8Hro4iqv_cNorbRiJCxXt-XmFifeyBNwLof@xxxxxxxxxxxxxx> <AANLkTim6KnxvKXbJmUQrUqm+mCBMU=y2maB0PitOfBfC@xxxxxxxxxxxxxx> <20101009221700.GA60765@xxxxxxxxxxxxxxxxxxxx>
 
On 18:17 Sat 09 Oct 2010, Phil Pennock wrote:
> The dropping is short-circuiting, the same as in all shell evaluation of
> && and ||.  The shell stops once it knows enough to know the answer.  So
> false to the left of && will stop, and true to the left of || will stop.
> 
> % [[ 1 == 1 && 3 == 2 && 4 == 4 && sb == sb ]]
> +zsh:12> [[ 1 == 1 && 3 == 2 ]]
> % [[ 1 == 1 && 3 != 2 && 4 == 4 && sb == sb ]]
> +zsh:13> [[ 1 == 1 && 3 != 2 && 4 == 4 && sb == sb ]]
> 
> So the issue appears to just be what the OP wrote, that =~ is messing up
> &&/|| by inserting a sense inversion.
> 
> % [[ 1 =~ 0 || 1 == 1 ]]
> +zsh:18> [[ 1 -regex-match 0 || ! 1 == 1 ]]
> % [[ 1 -regex-match 0 || 1 == 1 ]]
> +zsh:19> [[ 1 -regex-match 0 || 1 == 1 ]]
> 
> So it's related to use of =~ rather than -regex-match.  It's independent
> of whether or not zsh/pcre is loaded.  So this is probably a bug which I
> introduced when I wrote the =~ syntax support.  Looking now.
Did you find anything? Curious on what the state of this is.
Let me know if I can help.
Thanks,
	Brandon
Messages sorted by:
Reverse Date,
Date,
Thread,
Author