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

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

From
Ted Pavlic <ted@tedpavlic.com>
Date
Jan 12, 2009, 21:11 UTC
Message-ID
<496BB204.2040109@tedpavlic.com>
In-Reply-To
<200901121435.35547.bss@iguanasuicide.net>
>>          if [ -z "${1-}" ]
>
> That looks ugly to me.  Any reason we shouldn't just "set +u" at the top of
> the script?

As already discussed, because the script must be sourced, then the "set +u" has global scope.

I suppose that the option could be tested and then reset as appropriate at the end of the script.

(note: for some reason Mercurial's bash completion script does not have this problem; they use $1 directly without bash complaining)

-- 
Ted Pavlic <ted@tedpavlic.com>

   Please visit my ALS association page:
         http://web.alsa.org/goto/tedpavlic
   My family appreciates your support in the fight to defeat ALS.
Previous: Boyd Stephen Smith Jr.Next: Ted Pavlic
Message 7 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.