Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: =~ regex match
- X-seq: zsh-workers 23333
- From: Phil Pennock <zsh-workers+phil.pennock@xxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxx
- Subject: Re: PATCH: =~ regex match
- Date: Thu, 26 Apr 2007 17:06:36 -0700
- 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=;
- In-reply-to: <20070426201928.GA52120@xxxxxxxxxxxxxxxxxxxx>
- Mail-followup-to: zsh-workers@xxxxxxxxxx
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <20070426041938.GA44533@xxxxxxxxxxxxxxxxxxxx> <200704260931.l3Q9V2Ak014589@xxxxxxxxxxxxxx> <20070426201928.GA52120@xxxxxxxxxxxxxxxxxxxx>
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author