[PATCH 2/8] git-prompt: fix uninitialized variable
- From
- Avi Halachmi (:avih) via GitGitGadget <gitgitgadget@gmail.com>
- Date
- Jul 23, 2024, 19:18 UTC
- Message-ID
- <680ecb524040c64f886c4e484a64f0d17b512e27.1721762306.git.gitgitgadget@gmail.com>
- In-Reply-To
- <pull.1750.git.git.1721762306.gitgitgadget@gmail.com>
From: "Avi Halachmi (:avih)" <avihpit@yahoo.com>
First use is in the form: local var; ...; var=$var$whatever...
If the variable was unset (as bash and others do after "local x"), then it would error if set -u is in effect.
Also, many shells inherit the existing value after "local var" without init, but in this case it's unlikely to have a prior value.
Now we initialize it.
(local var= is enough, but local var="" is the custom in this file)
Signed-off-by: Avi Halachmi (:avih) <avihpit@yahoo.com> --- contrib/completion/git-prompt.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh index ebf2e30d684..4cc2cf91bb6 100644 --- a/contrib/completion/git-prompt.sh +++ b/contrib/completion/git-prompt.sh @@ -116,7 +116,7 @@ printf -v __git_printf_supports_v -- '%s' yes >/dev/null 2>&1 __git_ps1_show_upstream () { local key value - local svn_remote svn_url_pattern count n + local svn_remote svn_url_pattern="" count n local upstream_type=git legacy="" verbose="" name="" svn_remote=()
-- gitgitgadget