From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7656 invoked by alias); 2 Nov 2017 19:57:34 -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: List-Unsubscribe: X-Seq: 41977 Received: (qmail 28685 invoked by uid 1010); 2 Nov 2017 19:57:34 -0000 X-Qmail-Scanner-Diagnostics: from mx.spodhuis.org 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(94.142.241.89):SA:0(-4.2/5.0):. Processed in 1.508912 secs); 02 Nov 2017 19:57:34 -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=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: zsh-workers+phil.pennock@spodhuis.org X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | 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; Date: Thu, 2 Nov 2017 15:57:26 -0400 From: Phil Pennock To: Sebastian Gniazdowski Cc: zsh-workers@zsh.org Subject: Re: Localize MATCH, MBEGIN, etc. in _zstyle and _globquals Message-ID: <20171102195725.GA25362@tower.spodhuis.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: OpenPGP: url=https://www.security.spodhuis.org/PGP/keys/0x4D1E900E14C1CC04.asc 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@spodhuis.org) 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