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

Re: [PATCH] Update bash completions to prevent unbound variable errors.

From
Adeodato Simó <dato@net.com.org.es>
Date
Jan 12, 2009, 21:47 UTC
Message-ID
<20090112214729.GC24941@chistera.yi.org>
In-Reply-To
<496BB810.30503@tedpavlic.com>
* Ted Pavlic [Mon, 12 Jan 2009 16:37:20 -0500]:
>> Because (from a quick look) their completion script never expands a
>> variable which is not known to be set.
> They use $1, $2, etc. In fact, they use $1, $2, and $3 in their _hg,  
> which is their main completion function. Why would those be defined 
> there?
From http://www.gnu.org/software/bash/manual/bashref.html#Programmable-Completion:
  When the function or command is invoked, the first argument is the name
  of the command whose arguments are being completed, the second argument
  is the word being completed, and the third argument is the word
  preceding the word being completed on the current command line.
> In fact, it's $1, $2, $3, and $4 that are causing the problemw ith the  
> git completions.

They are causing problems in the functions that are called sometimes with arguments, sometimes without, like __gitdir. If you know that you'll always be calling a function with $1, you need not use ${1-}; that's what happens in the mercurial completion script AFAICS.

-- 
Adeodato Simó                                     dato at net.com.org.es
Debian Developer                                  adeodato at debian.org
 
The surest way to corrupt a youth is to instruct him to hold in higher
esteem those who think alike than those who think differently.
                -- F. Nietzsche
Previous: Ted PavlicNext: Adeodato Simó
Message 13 of 14 in “Update bash completions to prevent unbound variable errors.”
  1. Update bash completions to prevent unbound variable errors.Ted Pavlic, Jan 12, 2009
  2. Boyd Stephen Smith Jr.Jan 12, 2009
  3. Adeodato SimóJan 12, 2009
  4. Boyd Stephen Smith Jr.Jan 12, 2009
  5. Shawn O. PearceJan 12, 2009
  6. Boyd Stephen Smith Jr.Jan 12, 2009
  7. Ted PavlicJan 12, 2009
  8. Ted PavlicJan 12, 2009
  9. Shawn O. PearceJan 12, 2009
  10. Ted PavlicJan 12, 2009
  11. Adeodato SimóJan 12, 2009
  12. Ted PavlicJan 12, 2009
  13. Adeodato SimóJan 12, 2009
  14. Adeodato SimóJan 12, 2009

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.