How can you write a shell function that can find out if it was called from a compound command so that it can modify it's own behavior? It must do its magic thing only when called in isolation:
$ magic_function;
There should be no magic when it's part of a compound command, e.g.:
date; magic_function; uptime;
for i in LIST; do magic_function; done;
function funky () { do_this; magic_function; do_that; }
I've looked through the BASH manpage and exhausted my ideas around $BASH_COMMAND and $READLINE_LINE.
For some context, the function manipulates the shell history with history -s. It should not do that if it was called as part of a compound. I can find out if it was called from a function by inspecting $FUNCNAME.