]> git.ipfire.org Git - thirdparty/git.git/commitdiff
completion: avoid aliased command lookup error in nounset mode
authorVille Skyttä <ville.skytta@iki.fi>
Fri, 16 Apr 2021 19:19:39 +0000 (22:19 +0300)
committerJunio C Hamano <gitster@pobox.com>
Fri, 16 Apr 2021 20:40:52 +0000 (13:40 -0700)
Aliased command lookup accesses the `list` variable before it has been
set, causing an error in "nounset" mode. Initialize to an empty string
to avoid that.

    $ git nonexistent-command <Tab>bash: list: unbound variable

Signed-off-by: Ville Skyttä <ville.skytta@iki.fi>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/completion/git-completion.bash

index 1de74f10dd1caf035fa2abf14b2f86038d127781..cd3b13b67b251e67c4aec53682cdd4595b69f6c4 100644 (file)
@@ -1129,7 +1129,7 @@ __git_pretty_aliases ()
 # __git_aliased_command requires 1 argument
 __git_aliased_command ()
 {
-       local cur=$1 last list word cmdline
+       local cur=$1 last list= word cmdline
 
        while [[ -n "$cur" ]]; do
                if [[ "$list" == *" $cur "* ]]; then