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

Re: [PATCH] bash-completion: Support running with set -u in bash 4.0

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 6, 2010, 19:29 UTC
Message-ID
<7vtystfdu5.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20100306181655.GA2261@progeny.tock>
Jonathan Nieder <jrnieder@gmail.com> writes:
Show 6 quoted lines
> From: Thomas Nilsson <thomas.nilsson@unixangst.com>
> Date: Tue, 23 Feb 2010 12:13:00 +0100
>
> Starting with bash 4.0-beta, under "set -u" semantics, accessing
> undefined local variables is now an error.  Some user environments
> enable this setting in the interactive shell, with unpleasant results:
Unfortunate but necessary, it seems.
Show 9 quoted lines
> @@ -2181,7 +2181,7 @@ _git ()
>  		c=$((++c))
>  	done
>  
> -	if [ -z "$command" ]; then
> +	if [ -z "${command-}" ]; then
>  		case "${COMP_WORDS[COMP_CWORD]}" in
>  		--*)   __gitcomp "
>  			--paginate
Why not this patch, instead of the above hunk?

Also if we initialize __git_dir with an empty string on the same line, I think we can lose "${__git_dir-}" ugliness in __gitdir () function.

 contrib/completion/git-completion.bash |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index fe93747..3a65156 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -2167,7 +2167,7 @@ _git_tag ()
 
 _git ()
 {
-	local i c=1 command __git_dir
+	local i c=1 command="" __git_dir
 
 	while [ $c -lt $COMP_CWORD ]; do
 		i="${COMP_WORDS[c]}"
Previous: Jonathan NiederNext: Jonathan Nieder
Message 2 of 3 in “bash-completion: Support running with set -u in bash 4.0”
  1. bash-completion: Support running with set -u in bash 4.0Jonathan Nieder, Mar 6, 2010
  2. Junio C HamanoMar 6, 2010
  3. Jonathan NiederMar 6, 2010

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.