I can get a function myHandler()
to execute before a bash
command by doing the following:
function myHandler() {
...
}
trap 'myHandler' DEBUG
However, I'd like to be able to proceed with or abort the execution of the impending BASH_COMMAND
based on a runtime condition within myHandler
as follows:
function myHandler() {
if ! myCondition ; then
abort the execution of BASH_COMMAND right here
fi
# Proceed with the execution of BASH_COMMAND
}
Is this possible?