{"thread":{"id":"53770","subject":"[PATCH] completion: nounset mode fixes","startedAt":"2020-06-29T21:11:49Z","lastAt":"2020-06-29T21:11:49Z","messageCount":1,"participants":["Ville Skyttä"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"400768","messageId":"20200629185945.29814-1-ville.skytta@iki.fi","threadId":"53770","inReplyTo":null,"subject":"[PATCH] completion: nounset mode fixes","fromName":"Ville Skyttä","fromEmail":"ville.skytta@iki.fi","sentAt":"2020-06-29T18:59:45Z","receivedAt":"2020-06-29T21:11:49Z","isPatch":true,"sender":{"key":"ville.skytta@iki.fi","avatar":"https://avatars.githubusercontent.com/u/109152?v=4"},"body":"Accessing unset variables results an errors when the shell is in\nnounset/-u mode. This fixes the cases I've come across while using git\ncompletion in a shell running in that mode for a while. It's hard to\ntell if this is the complete set, but at least it improves things.\n\nSigned-off-by: Ville Skyttä <ville.skytta@iki.fi>\n---\n contrib/completion/git-completion.bash | 18 +++++++++---------\n 1 file changed, 9 insertions(+), 9 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex de5d0fbbd1..ee468ea3b0 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -50,7 +50,7 @@ esac\n # variable.\n __git_find_repo_path ()\n {\n-\tif [ -n \"$__git_repo_path\" ]; then\n+\tif [ -n \"${__git_repo_path-}\" ]; then\n \t\t# we already know where it is\n \t\treturn\n \tfi\n@@ -404,12 +404,12 @@ __gitcomp_builtin ()\n \t# spaces must be replaced with underscore for multi-word\n \t# commands, e.g. \"git remote add\" becomes remote_add.\n \tlocal cmd=\"$1\"\n-\tlocal incl=\"$2\"\n-\tlocal excl=\"$3\"\n+\tlocal incl=\"${2-}\"\n+\tlocal excl=\"${3-}\"\n \n \tlocal var=__gitcomp_builtin_\"${cmd/-/_}\"\n \tlocal options\n-\teval \"options=\\$$var\"\n+\teval \"options=\\${$var-}\"\n \n \tif [ -z \"$options\" ]; then\n \t\t# leading and trailing spaces are significant to make\n@@ -801,7 +801,7 @@ __git_refs ()\n #                --remote is only compatible with --mode=refs.\n __git_complete_refs ()\n {\n-\tlocal remote dwim pfx cur_=\"$cur\" sfx=\" \" mode=\"refs\"\n+\tlocal remote= dwim= pfx= cur_=\"$cur\" sfx=\" \" mode=\"refs\"\n \n \twhile test $# != 0; do\n \t\tcase \"$1\" in\n@@ -1152,7 +1152,7 @@ __git_find_on_cmdline ()\n \twhile [ $c -lt $cword ]; do\n \t\tfor word in $wordlist; do\n \t\t\tif [ \"$word\" = \"${words[c]}\" ]; then\n-\t\t\t\tif [ -n \"$show_idx\" ]; then\n+\t\t\t\tif [ -n \"${show_idx-}\" ]; then\n \t\t\t\t\techo \"$c $word\"\n \t\t\t\telse\n \t\t\t\t\techo \"$word\"\n@@ -1468,7 +1468,7 @@ __git_checkout_default_dwim_mode ()\n {\n \tlocal last_option dwim_opt=\"--dwim\"\n \n-\tif [ \"$GIT_COMPLETION_CHECKOUT_NO_GUESS\" = \"1\" ]; then\n+\tif [ \"${GIT_COMPLETION_CHECKOUT_NO_GUESS-}\" = \"1\" ]; then\n \t\tdwim_opt=\"\"\n \tfi\n \n@@ -3350,7 +3350,7 @@ __git_main ()\n \t\t((c++))\n \tdone\n \n-\tif [ -z \"$command\" ]; then\n+\tif [ -z \"${command-}\" ]; then\n \t\tcase \"$prev\" in\n \t\t--git-dir|-C|--work-tree)\n \t\t\t# these need a path argument, let's fall back to\n@@ -3385,7 +3385,7 @@ __git_main ()\n \t\t\t\"\n \t\t\t;;\n \t\t*)\n-\t\t\tif test -n \"$GIT_TESTING_PORCELAIN_COMMAND_LIST\"\n+\t\t\tif test -n \"${GIT_TESTING_PORCELAIN_COMMAND_LIST-}\"\n \t\t\tthen\n \t\t\t\t__gitcomp \"$GIT_TESTING_PORCELAIN_COMMAND_LIST\"\n \t\t\telse\n-- \n2.17.1\n\n"}]}