Suppose one executes either. some_scriptorsource some_scriptHow can some_script determine the absolute path of the current shell (i.e. the one that is executing the . or source command)?  (Note that, in general, this path is not the same as the value of $SHELL.)In other words, I'm looking for the absolute path counterpart of $$.  I figure that the current shell process must know the executable whence it came, but AFAICT, it's not stored in any environment variable.The best I can come up with boils down to scraping the output generated by a suitable variant of ps -p $$; for example:CURRENT_SHELL=${$( PS_FORMAT=cmd PS_PERSONALITY=linux ps -p $$ -h )% *}This is probably not very portable.  (And it's ugly, to boot.)I'm primarily interested in the case where the current shell is some version of zsh.  (I have a secondary interest in the corresponding answer for bash.)
How to get absolute path of current shell in a sourced script?
shell script;zsh