Q: Is there a way to tell why DEBUG trap was triggered?
From:
Šimon Let
Subject:
Q: Is there a way to tell why DEBUG trap was triggered?
Date:
Sun, 15 Mar 2020 12:41:36 +0100
Hi All,
I'm using PROMPT_COMMAND and DEBUG trap to emulate "PRE" and "POST" hooks
in bash. I have run into the issue where the DEBUG trap gets triggered when
any custom readline widget/function is executed. I would like to
programmatically determine if the DEBUG trap was triggered for a "real"
interactive command or if it was triggered for a custom readline widget.
I tried to use READLINE_LINE and READLINE_POINT variables but these are not
set during the DEBUG trap.
Is there another way that can be used to determine why the DEBUG trap was
triggered?
PS: I'm wondering what is your opinion on providing PRE and POST functions
natively in bash?
Thank you,
Šimon Let