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

[PATCH] completion: avoid aliased command lookup error in nounset mode

From
Ville Skyttä <ville.skytta@iki.fi>
Date
Apr 16, 2021, 19:19 UTC
Message-ID
<20210416191939.1120651-1-ville.skytta@iki.fi>

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>
---
 contrib/completion/git-completion.bash | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index dfa735ea62..49e76e9d08 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -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
-- 
2.25.1
Next: Junio C Hamano
Message 1 of 2 in “completion: avoid aliased command lookup error in nounset mode”
  1. completion: avoid aliased command lookup error in nounset modeVille Skyttä, Apr 16, 2021
  2. Junio C HamanoApr 16, 2021

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.