Trap on DEBUG not removed with shellhistory disable
pawamoy opened this issue · 0 comments
pawamoy commented
It seems to be because trap - DEBUG
is run inside of a function (_shellhistory_disable
).
A quick fix for this is to use PROMPT_COMMAND
to unset it instead:
new_prompt_command=${PROMPT_COMMAND//_shellhistory_after;}
PROMPT_COMMAND="trap '${trap:--}' DEBUG; PROMPT_COMMAND='${new_prompt_command}'"
Explanation:
- first we compute the new prompt command (the one without shellhistory)
- then we set PROMPT_COMMAND to:
- a command that will update the trap (when $trap is not empty) or remove it (when $trap is empty, will be replaced by
-
) - and a command that will set it to the new prompt command
- a command that will update the trap (when $trap is not empty) or remove it (when $trap is empty, will be replaced by