1
0
mirror of https://github.com/Llewellynvdm/starship.git synced 2024-12-01 01:04:00 +00:00

fix(bash): Restore previous exit status in bash init (#3521)

* fix: Restore previous exit status in bash init

* Do it correctly this time
This commit is contained in:
Kevin Song 2022-01-30 03:52:51 -06:00 committed by GitHub
parent 65f29754d3
commit 6e24358052
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -12,6 +12,9 @@
# drawn, and only start the timer if this flag is present. That way, timing is # drawn, and only start the timer if this flag is present. That way, timing is
# for the entire command, and not just a portion of it. # for the entire command, and not just a portion of it.
# A way to set '$?', since bash does not allow assigning to '$?' directly
function _starship_set_return() { return "${1:-0}"; }
# Will be run before *every* command (even ones in pipes!) # Will be run before *every* command (even ones in pipes!)
starship_preexec() { starship_preexec() {
# Save previous command's last argument, otherwise it will be set to "starship_preexec" # Save previous command's last argument, otherwise it will be set to "starship_preexec"
@ -43,6 +46,10 @@ starship_precmd() {
# Run the bash precmd function, if it's set. If not set, evaluates to no-op # Run the bash precmd function, if it's set. If not set, evaluates to no-op
"${starship_precmd_user_func-:}" "${starship_precmd_user_func-:}"
# Set $? to the preserved value before running additional parts of the prompt
# command pipeline, which may rely on it.
_starship_set_return "$STARSHIP_CMD_STATUS"
eval "$_PRESERVED_PROMPT_COMMAND" eval "$_PRESERVED_PROMPT_COMMAND"
# Prepare the timer data, if needed. # Prepare the timer data, if needed.