Skip to content

Commit ab6acb3

Browse files
committed
fix: Handle empty PROMPT_COMMAND in eternal bash history config
Use parameter expansion ${PROMPT_COMMAND:+; $PROMPT_COMMAND} to conditionally append existing PROMPT_COMMAND only if it's set and non-empty, avoiding syntax errors from trailing semicolons.
1 parent 1ba7a1b commit ab6acb3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

doc/harden-ubuntu-lts-24.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ export HISTTIMEFORMAT="[%F %T] "
363363
export HISTFILE=~/.bash_eternal_history
364364
# Force prompt to write history after every command.
365365
# http://superuser.com/questions/20900/bash-history-loss
366-
PROMPT_COMMAND="history -a; \$PROMPT_COMMAND"
366+
PROMPT_COMMAND="history -a\${PROMPT_COMMAND:+; \$PROMPT_COMMAND}"
367367
EOF
368368
else
369369
log "Eternal bash history already configured"

0 commit comments

Comments
 (0)