zsh-workers
 help / color / mirror / code / Atom feed
From: Phil Pennock <zsh-workers+phil.pennock@spodhuis.org>
To: zsh-workers@sunsite.dk
Subject: Re: PATCH: =~ regex match
Date: Thu, 26 Apr 2007 17:06:36 -0700	[thread overview]
Message-ID: <20070427000636.GA56088@redoubt.spodhuis.org> (raw)
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


  reply	other threads:[~2007-04-27  0:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-26  4:19 Phil Pennock
2007-04-26  5:12 ` Phil Pennock
2007-04-26  9:31 ` Peter Stephenson
2007-04-26 20:19   ` Phil Pennock
2007-04-27  0:06     ` Phil Pennock [this message]
2007-04-27  9:33     ` Peter Stephenson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070427000636.GA56088@redoubt.spodhuis.org \
    --to=zsh-workers+phil.pennock@spodhuis.org \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).