Several ways, from most to least reliable (and most-to-least "heavy"):
ps -p$$ -ocmd=. (On Solaris, this may need to be
cmd. On OSX and on BSD should be
- Check for
$ZSH_VERSION, and other shell-specific variables.
$SHELL; this is a last resort, as it specifies your default shell and not necessarily the current shell.