@@ -36,7 +36,7 @@ starship_precmd() {
36
36
if [[ ${BLE_ATTACHED-} && ${# BLE_PIPESTATUS[@]} -gt 0 ]]; then
37
37
STARSHIP_PIPE_STATUS=(" ${BLE_PIPESTATUS[@]} " )
38
38
fi
39
- if [[ " ${# BP_PIPESTATUS[@]} " -gt " ${# STARSHIP_PIPE_STATUS[@]} " ]]; then
39
+ if [[ -n " ${BP_PIPESTATUS-} " ]] && [[ " ${# BP_PIPESTATUS[@]} " -gt " ${# STARSHIP_PIPE_STATUS[@]} " ]]; then
40
40
STARSHIP_PIPE_STATUS=(${BP_PIPESTATUS[@]} )
41
41
fi
42
42
@@ -65,11 +65,13 @@ starship_precmd() {
65
65
# command pipeline, which may rely on it.
66
66
_starship_set_return " $STARSHIP_CMD_STATUS "
67
67
68
- eval " $_PRESERVED_PROMPT_COMMAND "
68
+ if [[ -n " ${_PRESERVED_PROMPT_COMMAND-} " ]]; then
69
+ eval " $_PRESERVED_PROMPT_COMMAND "
70
+ fi
69
71
70
72
local -a ARGS=(--terminal-width=" ${COLUMNS} " --status=" ${STARSHIP_CMD_STATUS} " --pipestatus=" ${STARSHIP_PIPE_STATUS[*]} " --jobs=" ${NUM_JOBS} " )
71
73
# Prepare the timer data, if needed.
72
- if [[ $ STARSHIP_START_TIME ]]; then
74
+ if [[ -n " ${ STARSHIP_START_TIME-} " ]]; then
73
75
STARSHIP_END_TIME=$( ::STARSHIP:: time)
74
76
STARSHIP_DURATION=$(( STARSHIP_END_TIME - STARSHIP_START_TIME))
75
77
ARGS+=( --cmd-duration=" ${STARSHIP_DURATION} " )
@@ -90,7 +92,7 @@ if [[ ${BLE_VERSION-} && _ble_version -ge 400 ]]; then
90
92
blehook PRECMD! =' starship_precmd'
91
93
# If the user appears to be using https://github.com/rcaloras/bash-preexec,
92
94
# then hook our functions into their framework.
93
- elif [[ " ${__bp_imported:- } " == " defined" || $ preexec_functions || $ precmd_functions ]]; then
95
+ elif [[ " ${__bp_imported:- } " == " defined" || -n " ${ preexec_functions-} " || -n " ${ precmd_functions-} " ]]; then
94
96
# bash-preexec needs a single function--wrap the args into a closure and pass
95
97
starship_preexec_all (){ starship_preexec " $_ " ; }
96
98
preexec_functions+=(starship_preexec_all)
111
113
112
114
# Finally, prepare the precmd function and set up the start time. We will avoid to
113
115
# add multiple instances of the starship function and keep other user functions if any.
114
- if [[ -z " $PROMPT_COMMAND " ]]; then
116
+ if [[ -z " ${ PROMPT_COMMAND-} " ]]; then
115
117
PROMPT_COMMAND=" starship_precmd"
116
118
elif [[ " $PROMPT_COMMAND " != * " starship_precmd" * ]]; then
117
119
# Appending to PROMPT_COMMAND breaks exit status ($?) checking.
0 commit comments