git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [RFC/PATCH] completion: avoid "words" as variable name for zsh portability

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Apr 27, 2011, 09:49 UTC
Message-ID
<BANLkTi=3T2B=Gtyk7V_3DB3V+GkbXAaqPw@mail.gmail.com>
In-Reply-To
<20110427091140.GB14849@elie>
On Wed, Apr 27, 2011 at 12:11 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:
Show 19 quoted lines
> Felipe Contreras wrote:
>> On Wed, Apr 27, 2011 at 9:40 AM, Jonathan Nieder <jrnieder@gmail.com> wrote:
>
>>> Sorry, I got carried away (I am happy to see someone has made some
>>> headway in investigating this old bug).  How about this?
>>
>> What's wrong with my patch?
>
> As mentioned at
> http://thread.gmane.org/gmane.comp.version-control.git/172142/focus=172157
> it breaks the tab completion in the common case that the user uses
> the standard bash completion library (usually provided at
> /etc/bash_completion) and git uses its _get_comp_words_by_ref
> function.  You can test like so:
>
>        % bash
>        $ . /etc/bash_completion
>        $ . contrib/completion/git-completion.bash
>        $ git fetch origin <TAB>

Where does that 'bash_completion' file comes from? I don't have it on my system. Do we really need to use _get_comp_words_by_ref from there? Can't we have our own _get_comp_words_by_ref?

Show 5 quoted lines
> I also made a small cosmetic change which is less important (sorry, I
> should have mentioned it before): the patch I sent spells out
> comp_words instead of writing cwords to avoid a false analogy between
> the array of all completion words (cwords) and the current word index
> (cword).

I don't see how cword can be confused with cwords. Besides, I prefer uniformity, so if you use comp_words, cword should be cur_word, or word_index, or something like that.

Show 9 quoted lines
>>> There is still a "for unknown reasons" in the above explanation.
>>
>> I'm asking zsh guys:
>> http://www.zsh.org/mla/workers/2011/msg00515.html
>
> Thanks.  It looks like to get the semantics I expect from "local"
> in zsh, one needs to use "typeset -h" (which bash does not support,
> unfortunately).  Probably it is best to steer clear of zsh's special
> variables anyway.

Hmm, interesting, maybe we should try to find a way to replace those 'local' with 'typeset -h'.

-- 
Felipe Contreras
Previous: Jonathan NiederNext: John Szakmeister
Message 8 of 28 in “git-completion: fix zsh support”
  1. git-completion: fix zsh supportFelipe Contreras, Apr 27, 2011
  2. Jonathan NiederApr 27, 2011
  3. Felipe ContrerasApr 27, 2011
  4. Junio C HamanoApr 27, 2011
  5. completion: avoid "words" as variable name for zsh portabilityJonathan Nieder, Apr 27, 2011
  6. Felipe ContrerasApr 27, 2011
  7. Jonathan NiederApr 27, 2011
  8. Felipe ContrerasApr 27, 2011
  9. John SzakmeisterApr 27, 2011
  10. Felipe ContrerasApr 27, 2011
  11. completion: move private shopt shim for zsh to __git_ namespaceJonathan Nieder, Apr 27, 2011
  12. Felipe ContrerasApr 27, 2011
  13. Jonathan NiederApr 27, 2011
  14. Jonathan NiederMay 6, 2011
  15. Felipe ContrerasMay 6, 2011
  16. SZEDER GáborMay 8, 2011
  17. SZEDER GáborApr 28, 2011
  18. 1/3 bash: don't modify the $cur variable in completion functionsSZEDER Gábor, Apr 28, 2011
  19. 2/3 bash: remove unnecessary _get_comp_words_by_ref() invocationsSZEDER Gábor, Apr 28, 2011
  20. 3/3 bash: don't declare 'local words' to make zsh happySZEDER Gábor, Apr 28, 2011
  21. Felipe ContrerasMay 3, 2011
  22. Felipe ContrerasApr 28, 2011
  23. Junio C HamanoApr 28, 2011
  24. Felipe ContrerasApr 28, 2011
  25. Felipe ContrerasApr 27, 2011
  26. Junio C HamanoApr 27, 2011
  27. Felipe ContrerasApr 27, 2011
  28. Jonathan NiederApr 27, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.