How to detect if bash shell command is followed by a logical && AND or || OR?
No. The general answer is to move notification outside of your commands:
b && b2; notify-result $?
Now, if you're implementing b
and b2
as shell functions rather than external commands, you can do some introspection -- looking at the BASH_SOURCE
array to inspect the stack frames involved in code's invocation -- but that's extremely fragile, and by no means a good practice.