From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25150 invoked by alias); 3 May 2011 17:36:49 -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: X-Seq: 29142 Received: (qmail 11260 invoked from network); 3 May 2011 17:36:46 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.google.com designates 209.85.161.43 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=2/xOnjGBjahs9yCfFtAHIs1+cInjZjtZla42TgLzuvs=; b=IRsO9KqzxJ+5JwpbgvvJiDkQYlTxRhiD47Hsk2I3CaxQdBuVlJnE9XHa11pfOPQK8V Syz8+vpr6U3ANB0q6SYb9OIp3sIfichx2m4f/+FbXZ064bucorgRhefQ5I6mgcxAV6yd IMf8eprhfdhe8uUAY2llryolZRw2VHgRPdogw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=fwsesGAVAdqRJMX4o5nkWGAcF/jwKJzAwxPFtF0LWj4fn675AcKPhFvTTo6iAWXnvJ yk1kOpg9Qzj2dgM0wc3FezBahLPb7hl2s/Uz8r04AmWU0rbTVk4LcJqEp3wvd/MAUfFw MkucnAcfA/MvlB+Zzly866iu/eIz/L4raTwug= MIME-Version: 1.0 In-Reply-To: <110503073902.ZM15889@torch.brasslantern.com> References: <110428203139.ZM11856@torch.brasslantern.com> <110502184235.ZM14465@torch.brasslantern.com> <110503073902.ZM15889@torch.brasslantern.com> Date: Tue, 3 May 2011 20:36:37 +0300 Message-ID: Subject: Re: zle messes up 'words' variable? From: Felipe Contreras To: Bart Schaefer Cc: zsh-workers@zsh.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Tue, May 3, 2011 at 5:39 PM, Bart Schaefer w= rote: > On May 3, 11:05am, Felipe Contreras wrote: > } > } The fact that it's documented as a special variable doesn't mean that > } the behavior should be totally unexpected. > } > } 1) Without modifier > } > } Then 'words' can be re-used like any other variable. > } > } 2) With 'local' modifier > } > } Then modifying 'words' has an impact only on the current function, not > } on the scope where the variable was defined as local. > > Ahh, I see the problem. =C2=A0You haven't read the entire documentation. > At the very top of (what in the info file is) section 19.2 is this > paragraph (caps mine for emphasis): > > =C2=A0 =C2=A0Inside completion widgets, AND ANY FUNCTIONS CALLED FROM THE= M, some > =C2=A0 =C2=A0parameters have special meaning; outside these functions the= y are > =C2=A0 =C2=A0not special to the shell in any way. These parameters are us= ed to > =C2=A0 =C2=A0pass information between the completion code and the complet= ion > =C2=A0 =C2=A0widget. Some of the builtin commands and the condition codes= use or > =C2=A0 =C2=A0change the current values of these parameters. Any existing = values > =C2=A0 =C2=A0will be hidden during execution of completion widgets; EXCEP= T FOR > =C2=A0 =C2=A0COMPSTATE, THE PARAMETERS ARE RESET ON EACH FUNCTION EXIT (I= NCLUDING > =C2=A0 =C2=A0NESTED FUNCTION CALLS FROM WITHIN THE COMPLETION WIDGET) to = the > =C2=A0 =C2=A0values they had when the function was entered. > > In other words, these variable are always local in all scopes, unless > they are explicitly declared otherwise (which in this case requires > the use of typeset -h). =C2=A0That's part of their special-ness, and is o= ne > of the things I assert is extremely unlikely to change. Except that 'words' is not really acting as local, and 'local' should be considered 'declared otherwise'. That's part of the weirdness. > } 2.1) When using #compdef tag > } > } Then 'words' can be modified like any other variable. > > I thought you'd decided you were unable to reproduce this? =C2=A0If you n= ow > *are* able to reproduce it, then *that* might be a bug. That's true. > } 3) With 'typedef -h' > } > } Then 'words' can be modified like any other variable. > } > } I was expecting an explanation of these discrepancies, and a way to > } globally make 'words' work as expected without having to replace each > } use of 'local' by 'typedef -h'. > > I apologize for not understanding the source of the mis-understanding. > I was focusing on why #compdef might make a difference, not on the > details of the actual scoping problem you perceived. I see. > } > If what you want to discuss is ways to fix bashcompinit so that the > } > functions in bash completion work as expected, that's one thing. =C2= =A0If > } > what you're asking is for the special-ness of "words" to be undone > } > for completion in general, that's so unlikely to happen as to not be > } > worth continuing. > } > } You are not good at compartmentalizing aren't you? > > I'm really disappointed in the way that mailing list discourse in > general lately (and not just on this list) tends to rapidly descend > into insults and ad-hominem attacks. =C2=A0I've been watching the CentOS > list collapse under the weight of this sort of thing and I plead that > we try to avoid it here. I didn't intend that as an insult; some people are good are compartmentalizing, some people are not. > } If you fix the issue with my example, you fix the issue with > } bashcompinit. It's the same issue. Or "riddle" if that word makes you > } more comfortable. > > No, it's not the same issue, because bashcompinit has responsibility > for loading the bash completion functions in a way that makes them > compatible. =C2=A0That's not the same as first loading bashcompinit and > then independently defining a new completion, though I lean toward > the conclusion that use of the bash-compatible "complete" command is > probably the correct place to fix this if it can be managed. Well, bashcompinit is also a script. If my script can be fixed without modifying _foo() or set_vars(), then the same fix can be applied to bashcompinit: +typeset -h words complete -F _foo foo --=20 Felipe Contreras