From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27844 invoked by alias); 9 Dec 2015 15:58: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: 37363 Received: (qmail 22284 invoked from network); 9 Dec 2015 15:58:27 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=MklRUi8XJ06DOzgaFMeBvTyay7pmQSq1nZnWTrc5NPE=; b=pbkM8gWaqCiuMwQotZeRGruQPyaSn023Myk0wTv7InZbrt1hqpx84RQCzzxQMaSyHp md4HD9TUI2Q2/c1hD03s0+zzRfm3GQPdWol6H+nWz7pgaEIIPu2rMqsHqrLSILYIwSr3 Dldfv9mVknCk0pcmTXb5smW4MLK0KxmBzR2VtK3Y9As7PBfTrBbJBXMcqm5VUI/Hg1uK RaRqQYybK1fMJz8c6RjHkIxWb1QlHUJj7dFLip4wJYiP7Y0uI8aDQLK/kw3/a+GAzHBr uTwQyDwUPuAHXJacIRBMHnsX+zqojtZF2R6nnbHfv3rjhWla6LcIjSuhGq/Nrk062xEO KwlA== X-Received: by 10.194.184.104 with SMTP id et8mr7310194wjc.87.1449676705421; Wed, 09 Dec 2015 07:58:25 -0800 (PST) Date: Wed, 9 Dec 2015 15:58:23 +0000 From: Stephane Chazelas To: Martijn Dekker Cc: zsh-workers@zsh.org Subject: Re: Bug: [ "(" = ")" ] is true Message-ID: <20151209155823.GA10749@chaz.gmail.com> Mail-Followup-To: Martijn Dekker , zsh-workers@zsh.org References: <56684A0A.8010404@inlv.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <56684A0A.8010404@inlv.org> User-Agent: Mutt/1.5.21 (2010-09-15) 2015-12-09 16:34:34 +0100, Martijn Dekker: > There is a string comparison bug with `[' and `test'; the result is true > if the first string starts with '(' and the second string starts with ')'. > > $ [ "(" = ")" ] && echo oops || echo ok > oops > $ [ ")" = "(" ] && echo oops || echo ok > ok > $ [ "((" = "))" ] && echo oops || echo ok > oops > $ [ "((" = ")x" ] && echo oops || echo ok > oops > $ [ "(x" = ")" ] && echo oops || echo ok > oops > $ [ "x(" = ")" ] && echo oops || echo ok > ok > $ [ "(" = "x)" ] && echo oops || echo ok > ok > > This appears to be a long-standing bug. I confirmed it in: > > zsh 4.3.6 > zsh 5.1.1 > zsh 5.2 > > I also found that the bug does *not* exist in zsh 4.1.1. [...] http://www.zsh.org/mla/users/2007/msg01223.html seems to be to blame. If the first argument starts with a "(" and the last one starts in a ")", they are both removed. So all operators are affected not just "=" ([ "(file1)" -nt ")file2(" ]...) -- Stephane