It's fairly straightforward to determine from within a script that the code being run is not running in an interactive shell, but you already know that as you write the script, so I'm not sure how it's useful except within a function (or if you source the script).
Within a script, how do you determine if the script is being run from an interactive shell, or being run by another script? In other words, how do you determine the interactivity of the caller of the script? Put yet another way, how do you know whether the parent shell is interactive or not?
Just to further clarify, I'm not trying to find the name of the nearest interactive ancestor, I'm just trying to figure out if the immediate parent is interactive or not.
If this varies from shell to shell, I'm most interested in zsh, but also in bash.