Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Localize MATCH, MBEGIN, etc. in _zstyle and _globquals
- X-seq: zsh-workers 41977
- From: Phil Pennock <zsh-workers+phil.pennock@xxxxxxxxxxxx>
- To: Sebastian Gniazdowski <psprint@xxxxxxxxxxx>
- Subject: Re: Localize MATCH, MBEGIN, etc. in _zstyle and _globquals
- Date: Thu, 2 Nov 2017 15:57:26 -0400
- Cc: zsh-workers@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=spodhuis.org; s=d201708; h=In-Reply-To:Content-Type:MIME-Version:References :Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding :Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=oGD9MTBGyWCh7JtWsCMxkP0jxszoF6NXHJmr5u42jgY=; b=LIcN5hzIMHJePE6ymc2i4Of9Hs RCjKgOy14rK7dij7uoU0W+KVqy2a+Hd1mCsMG3faZl0fi/cf4slXgPy3Ulog5eL9zs4f9lZ3+pU7i B1IMIyk/+KgDLptOCg5Hr5imTNy1+U7/jIVKsBsm1fHXrEst+4jj2oOs7wX8BGkNub4I3c11HYpKq 3ATfVK0BhB0FQL7IwFoPpjUXY6vc;
- In-reply-to: <etPan.59fb6d5b.6529e0b6.98a8@zdharma.org>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- Openpgp: url=https://www.security.spodhuis.org/PGP/keys/0x4D1E900E14C1CC04.asc
- References: <etPan.59f5be1b.1dad7c90.98a8@zdharma.org> <etPan.59f655ed.1f659851.98a8@AirmailxGenerated.am> <etPan.59fb6d5b.6529e0b6.98a8@zdharma.org>
On 2017-11-02 at 20:09 +0100, Sebastian Gniazdowski wrote:
> On 29 Oct 2017 at 23:07:21, Phil Pennock (zsh-workers+phil.pennock@xxxxxxxxxxxx) wrote:
> > Anyone know of a good reason to not just localize _all_ of the =~
> > non-BASH_REMATCH variables in _main_complete so that they're always
> > isolated to the completion-system, if =~ or -regex-match or -pcre-match
> > is used within the completion system?
>
> I'm little not current with regex match variables, so not sure what
> you mean by "=~" variables, and why not localize non-BASH_REMATCH
> variables too (or if it's that Zsh code doesn't use them, then it's ok
> for me, logical to not localize them).
I think we've hit an "overly tortured English written by Phil" problem
here. I _think_ we're pushing for the same goal.
If BASH_REMATCH is not set then various variables are set. I think
that _all_ of those should always be localized for the completion
system, but was asking if anyone has a convincing reason why not.
The variables are documented in zshmisc(1) in CONDITIONAL EXPRESSIONS
under >> string =~ regexp <<. Thus:
local MATCH MBEGIN MEND match mbegin mend
Note re your other point (not quoted by me above): once a variable name
is localized, it's local, and you don't need to force it to be an array
as long as whatever sets it treats it as the right type:
foo=(alpha beta)
baz() { foo=(gamma delta); typeset -p foo }
bar() { typeset -p foo ; local foo; baz }
bar
typeset -p foo
baz
typeset -p foo
=>
typeset -g -a foo=( alpha beta )
typeset -g -a foo=( gamma delta )
typeset -a foo=( alpha beta )
typeset -g -a foo=( gamma delta )
typeset -a foo=( gamma delta )
Thus the variable is always array, but the >>local<< in >>bar()<< works
to protect the global foo.
-Phil
Messages sorted by:
Reverse Date,
Date,
Thread,
Author