From e1189ed7567de580d8f51c8baf870056a6060789 Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Tue, 30 Jul 2024 04:43:41 +0900 Subject: [PATCH] fix(bash): fix variable leak in Bash integration (#6143) * fix(bash): quote array expansions to work around custom IFS * fix(bash): locally set standard IFS for $(jobs -p) * fix(bash): localize the leaked variable "job" --- src/init/starship.bash | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/init/starship.bash b/src/init/starship.bash index e08a9fbd..5ed7a8ed 100644 --- a/src/init/starship.bash +++ b/src/init/starship.bash @@ -32,12 +32,12 @@ starship_preexec() { # Will be run before the prompt is drawn starship_precmd() { # Save the status, because commands in this pipeline will change $? - STARSHIP_CMD_STATUS=$? STARSHIP_PIPE_STATUS=(${PIPESTATUS[@]}) + STARSHIP_CMD_STATUS=$? STARSHIP_PIPE_STATUS=("${PIPESTATUS[@]}") if [[ ${BLE_ATTACHED-} && ${#BLE_PIPESTATUS[@]} -gt 0 ]]; then STARSHIP_PIPE_STATUS=("${BLE_PIPESTATUS[@]}") fi if [[ -n "${BP_PIPESTATUS-}" ]] && [[ "${#BP_PIPESTATUS[@]}" -gt 0 ]]; then - STARSHIP_PIPE_STATUS=(${BP_PIPESTATUS[@]}) + STARSHIP_PIPE_STATUS=("${BP_PIPESTATUS[@]}") fi # Due to a bug in certain Bash versions, any external process launched @@ -52,7 +52,7 @@ starship_precmd() { # Original bug: https://lists.gnu.org/archive/html/bug-bash/2022-07/msg00117.html jobs &>/dev/null - local NUM_JOBS=0 + local job NUM_JOBS=0 IFS=$' \t\n' # Evaluate the number of jobs before running the preserved prompt command, so that tools # like z/autojump, which background certain jobs, do not cause spurious background jobs # to be displayed by starship. Also avoids forking to run `wc`, slightly improving perf.