Re: [PATCH v2 5/8] git-prompt: add some missing quotes
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Aug 15, 2024, 16:36 UTC
- Message-ID
- <xmqqmsldu4iu.fsf@gitster.g>
- In-Reply-To
- <4f77b7eb7f1110e47201b8c97c34a0cbcd14e24f.1723727653.git.gitgitgadget@gmail.com>
"Avi Halachmi (:avih) via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 5 quoted lines
> In _command-arguments_, expanded/substituted values must be quoted: > Good: [ "$mode" = yes ]; local s="*" x="$y" e="$?" z="$(cmd ...)" > Bad: [ $mode = yes ]; local s=* x=$y e=$? z=$(cmd...) > > Still in _agumemts_, no need to quote non-expandable values:
arguments.
Show 5 quoted lines
> - local bad_color=$c_red > - local ok_color=$c_green > + local bad_color="$c_red" > + local ok_color="$c_green" > local flags_color="$c_lblue"
Good. I think we in the past was burned by some shells that want to see these assignments with "local" always quoted.
> # preserve exit status > - local exit=$? > + local exit="$?" > local pcmode=no
Well no matter what value $? has, it by definition has a few digits without any $IFS funnies. Does this really matter? I'd imagine that we would prefer to treat "$?" exactly the same way as "no".
Show 7 quoted lines
> @@ -379,7 +379,7 @@ __git_ps1 ()
> ;;
> 0|1) printf_format="${1:-$printf_format}"
> ;;
> - *) return $exit
> + *) return "$exit"
> ;;Likewise.