From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4759 invoked by alias); 9 Sep 2016 16:06:37 -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: 39257 Received: (qmail 7760 invoked from network); 9 Sep 2016 16:06:37 -0000 X-Qmail-Scanner-Diagnostics: from mail-wm0-f42.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(74.125.82.42):SA:0(0.0/5.0):. Processed in 1.229076 secs); 09 Sep 2016 16:06:37 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM,SPF_PASS, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: stephane.chazelas@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 74.125.82.42 as permitted sender) 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-disposition:in-reply-to:user-agent; bh=aM8ND5/jLDa55KicNEAITRzRdRBa43XGwKlH+6Q9qzo=; b=UMfZyD9aw0+91tZV0nptzygunmKuWTMTq9eBs4LJLqjdSsvJzHemtjcVnZ8MDloz0B X8RTvAVnHjcXKJHYbaBNXq7IBz84/N8SYxQq6YYbaZrBuARKBd5f1S/zgeYCcIfNuDIQ ppMWgview9FafGsi7WrauQkrt/ncLb0AZa2ccbrVnm/vDLbEQlaoN3GN3wSpMIfUD3eJ L9756KHPp8PSkXBCtTafBybKYXtT2MSgQaCy+I6muz2Zk2a1DjA6w92J+YA3WXUZKw1S +p6EFr3QI5FwTL3Ri3fpU1AfSgDSZ8dyPN4pGsUBIwJTx/H7357rpHx0YLXFy4SPoUa6 xupQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to:user-agent; bh=aM8ND5/jLDa55KicNEAITRzRdRBa43XGwKlH+6Q9qzo=; b=M5iUjCsrmnAnYrkO/RhsZP6qqox+3aOpp4M0hmRC3zl/1uKUGNNjTpriRIG75PXXyC e8ZN1oYAyXKnh3BAB9vNkez6azQylYosYQ5/rPFpTjg09WI534aR/nsZ9GlMwFSE59nJ 8WpyKR8HpdWipMnxPNUIjaPNvc04+OZAPjoyxRb/ruV5AZLPRAjxX+L9DU4/V4+Ygwxz Mie6qAieehmoQOFXbVy8ECUgXXmKF1/7aV8zMMFYnKHTYlTHeh4+pyALb9yViwb59aKy 15bvXlOSKtoZ9+vHr3RrJ9Ka9epDxwysLbzsSX6iqizPjCQxg9Mk3ht7ntuDh4vJH8YF c/cg== X-Gm-Message-State: AE9vXwOk4Aq1cV4Rkf3N97An+SqQ3Op+L6mhDqRXJIC4UE6A7ArgYiv4DB3+IMgM6crwHA== X-Received: by 10.194.85.45 with SMTP id e13mr3809752wjz.5.1473436848599; Fri, 09 Sep 2016 09:00:48 -0700 (PDT) Date: Fri, 9 Sep 2016 17:00:46 +0100 From: Stephane Chazelas To: Peter Stephenson Cc: zsh-workers@zsh.org Subject: Re: [PATCH] Use == in expressions instead of the deprecated = Message-ID: <20160909160046.GB9717@chaz.gmail.com> Mail-Followup-To: Peter Stephenson , zsh-workers@zsh.org References: <20160905212754.24998-1-tgyurci@gmail.com> <20160908093516.4fc2dd1e@pwslap01u.europe.root.pri> <20160908121628.78977edd@pwslap01u.europe.root.pri> <20160908143128.GA14933@chaz.gmail.com> <20160909085231.GA9717@chaz.gmail.com> <20160909103155.2047b887@pwslap01u.europe.root.pri> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160909103155.2047b887@pwslap01u.europe.root.pri> User-Agent: Mutt/1.5.21 (2010-09-15) 2016-09-09 10:31:55 +0100, Peter Stephenson: > On Fri, 09 Sep 2016 09:52:31 +0100 > Stephane Chazelas wrote: > > It's still possible that the next major POSIX spec will have > > [ == ] and maybe even [[ ]]. > > > > You guys may want to comment on the latest proposal there: > > http://austingroupbugs.net/file_download.php?file_id=31&type=bug > > > > as it would make zsh non-conformant. > > > > In particular, it proposes specifying [[ =~ ]] the ksh/bash > > way, that is where quoting escapes regexp operators ( > > [[ a =~ "." ]] returns false) and [[ < ]] required to use > > collation. > > If POSIX-like shells already do it that way, the best we could offer > would probably be another kludge-up option anyway. Not specifying it, > the only other option, isn't really doing anyone any favours in the end. [...] Note that doing it properly is tricky. bash has had a number of bugs before it eventually settled to something reliable enough. bash -c '[[ "\\" =~ [^]"."] ]]' Still return false though. With zsh supporting both ERE and PCRE, it's going to be even more pain I would say. Specifying it (which the current proposal doesn't really address) is also going to be difficult. The problem is that the shell needs to know the syntax of the regular expressions in order to be able to quote the RE operators properly for the regexp engine. for instance in [[ x =~ "." ]], the shell has to call regcomp("\\."), but in [[ x =~ ["."] ]], it must call regcomp("[.]"), as otherwise a regcomp("[\.]") would also match on backslash. bash now does that properly in most cases (after I raised the bug some time ago), but misses the [^]...] case as I've just realised. And in [[ x =~ "<" ]], you don't want to do a regcomp("\\<"), as \< has a special meaning in some regexp engines. So bash does a regcomp("<") (for both [[ x =~ "<" ]] and [[ x =~ \< ]]) instead. What that means is that you can't use the extensions of your local regexp library unless you use a variable as in: var='\' [[ $x =~ $var ]] because then bash does a regcomp("\\") (just like zsh). See also: a='foo\' [[ 'foo\bar' =~ $a"." ]] That returns true in bash. (as it does a regcomp("foo\\\\.")), though here we are asking for trouble in the first place with that trailing backslash. In effect at the moment to use =~ portably between ksh, bash, bash31, zsh, you have to use: regex=... [[ $string =~ $regex ]] And in between yash and zsh: [ "$string" "=~" "$regex" ] In PCRE, you have things like (?x) that affect the parsing and would make things more complicated, but you might be able to leverage \Q \E. -- Stephane