From 54ccd1efb97445c07c233cadd43ab77a1d639a57 Mon Sep 17 00:00:00 2001 From: Doncho Gunchev Date: Sat, 17 Oct 2020 12:22:46 +0300 Subject: [PATCH] Don't add our prompt_command twice, also prepend During testing if you source it twice you get that problem now. The error code formatting/logging gets broken if we run prompt_command after other stuff. Running anything external obviously resets $?. --- bash/ps-twtty-7.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bash/ps-twtty-7.sh b/bash/ps-twtty-7.sh index 7ae24ce..ba3e894 100755 --- a/bash/ps-twtty-7.sh +++ b/bash/ps-twtty-7.sh @@ -154,7 +154,10 @@ ${C2})${C3}\$${NO_COLOUR} " if [ -z "${PROMPT_COMMAND}" ]; then export PROMPT_COMMAND=prompt_command else - export PROMPT_COMMAND="${PROMPT_COMMAND}; prompt_command" + if ! echo "${PROMPT_COMMAND}" | grep '\bprompt_command\b' > /dev/null 2>&1; then + export PROMPT_COMMAND="prompt_command +${PROMPT_COMMAND}" + fi fi trap prompt_command_exit EXIT shopt -s cmdhist histappend