From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15143 invoked by alias); 9 Oct 2010 22:32:45 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 28337 Received: (qmail 19082 invoked from network); 9 Oct 2010 22:32:42 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received-SPF: none (ns1.primenet.com.au: domain at spodhuis.org does not designate permitted sender hosts) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=spodhuis.org; s=d200912; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date; bh=euf0gLfDV7OCGyd1QYKchBscnn0QqHclqNvl6Pbl3Qg=; b=g7RqbCzc97W6ODGblwKTcslXxta5w0k+2d3Xcm8jqRvIw6vu2DHxF3Dg9sBTcxovoJerfWjqmG0myz4kl32cOd1kD962N2Il+HpkizTW9l3JQ/JCBHjzVppjtRLjNhI6BjvZaAU36mg6aZR9YmF4iP63FUHRokHPYLJlw4G/B+k=; Date: Sat, 9 Oct 2010 18:17:01 -0400 From: Phil Pennock To: Michael Hwang Cc: Mikael Magnusson , zsh workers , brandon@ifup.org Subject: Re: [[ 0 =~ 1 || 1 = 0 ]] returns true Message-ID: <20101009221700.GA60765@redoubt.spodhuis.org> Mail-Followup-To: Michael Hwang , Mikael Magnusson , zsh workers , brandon@ifup.org References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On 2010-10-09 at 16:06 -0400, Michael Hwang wrote: > % set -x > % [[ 0 =~ 1 || 1 = 0 ]] > +zsh:2> [[ 0 -regex-match 1 || ! 1 == 0 ]] > % [[ 0 =~ 1 || 1 == 1 || 1 = 0 ]] > +zsh:3> [[ 0 -regex-match 1 || ! 1 == 1 ]] > % [[ 0 =~ 1 || 1 == 1 || 1 = 1 || 1 = 1 || 1 = 1 ]] > +zsh:4> [[ 0 -regex-match 1 || ! 1 == 1 ]] > > It appears that zsh thinks it needs to invert the second conditional > expression. Also, zsh seems to drop more than two conditional > expressions. 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. -Phil