From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16802 invoked from network); 27 Apr 2007 00:06:50 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.8 (2007-02-13) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,FORGED_RCVD_HELO autolearn=ham version=3.1.8 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 27 Apr 2007 00:06:50 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 54393 invoked from network); 27 Apr 2007 00:06:44 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 27 Apr 2007 00:06:44 -0000 Received: (qmail 2814 invoked by alias); 27 Apr 2007 00:06:41 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 23333 Received: (qmail 2804 invoked from network); 27 Apr 2007 00:06:40 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 27 Apr 2007 00:06:40 -0000 Received: (qmail 54128 invoked from network); 27 Apr 2007 00:06:40 -0000 Received: from redoubt.spodhuis.org (HELO mx.spodhuis.org) (193.202.115.177) by a.mx.sunsite.dk with SMTP; 27 Apr 2007 00:06:37 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=first1; d=spodhuis.org; h=Received:Date:From:To:Subject:Message-ID:Mail-Followup-To:References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; b=bgwMYuEm2FtkWVSB3PEq4ErVPf1mnNkpvcdNil6OVAOfOzf8+J7QjvrQ1TAnckP1urKPxDOrW4D5KlZN170QEfGoRbW9GhPFn3fPVv1iTc3Xcd5y6owVVyUYT/vmPVy/mFRlsDh4t6I4U7PV8EPdgSa9Zq0YxNLDiwQkDPaafoU=; Received: by smtp.spodhuis.org with local id 1HhDyu-000FAG-KQ; Fri, 27 Apr 2007 00:06:36 +0000 Date: Thu, 26 Apr 2007 17:06:36 -0700 From: Phil Pennock To: zsh-workers@sunsite.dk Subject: Re: PATCH: =~ regex match Message-ID: <20070427000636.GA56088@redoubt.spodhuis.org> Mail-Followup-To: zsh-workers@sunsite.dk References: <20070426041938.GA44533@redoubt.spodhuis.org> <200704260931.l3Q9V2Ak014589@news01.csr.com> <20070426201928.GA52120@redoubt.spodhuis.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20070426201928.GA52120@redoubt.spodhuis.org> On 2007-04-26 at 13:19 -0700, Phil Pennock wrote: > As to BASH_REMATCH ... how frowned upon are new zsh options which > auto-set for compatibility? It wouldn't be hard, since the > infrastructure's all already in place. Call the zsh option BASH_REMATCH > to set the BASH_REMATCH variable. :^) I just double-checked something in passing and discovered that Bash uses the equivalent of KSH_ARRAYS, so the variable would need to be marked similarly to that and provided with the entire matched portion of the string in index 0. Would it be sufficient to assume that if someone's truly after bash compat, ksh_arrays will be set, so inside the test isset(BASHREMATCH) also check isset(KSHARRAYS) and if and only if that is set too, then prepend the entire matched portion to the array? Normal: set $MATCH to matched portion, ${match[@]} to captured substrings BASH_REMATCH: set $MATCH to matched portion, ${BASH_REMATCH} to captured substrings => not full compat BASH_REMATCH && KSH_ARRAYS set $MATCH to matched portion, ${BASH_REMATCH[0]} to matched portion too, ${BASH_REMATCH[1...n]} to captured substrings => full compat Which highlights that =~ should also be setting $MATCH, not just $match. Would it be okay to extend the -pcre-match operator to do the same? What about the pcre_match builtin function -- should that also be setting $MATCH and accept a "-v var" option to set a different variable, similarly to "-a arr"? If so, any preferences as to what the option should be? I'm willing to do this work, provided people think that it would be fairly likely to be accepted. Regards, -Phil