mirror of
https://github.com/starship/starship.git
synced 2024-11-24 17:23:49 +01:00
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"
This commit is contained in:
parent
d96fbc5bcb
commit
e1189ed756
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user