From: Junio C Hamano Date: Thu, 15 Aug 2024 16:36:41 GMT Subject: Re: [PATCH v2 5/8] git-prompt: add some missing quotes Message-ID: In-Reply-To: <4f77b7eb7f1110e47201b8c97c34a0cbcd14e24f.1723727653.git.gitgitgadget@gmail.com> "Avi Halachmi (:avih) via GitGitGadget" writes: > 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. > - 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". > @@ -379,7 +379,7 @@ __git_ps1 () > ;; > 0|1) printf_format="${1:-$printf_format}" > ;; > - *) return $exit > + *) return "$exit" > ;; Likewise.