2 Add note about -o option on OSX and on BSD
source | link

Several ways, from most to least reliable (and most-to-least "heavy"):

  1. ps -p$$ -ocmd=. (On Solaris, this may need to be fname instead of cmd. On OSX and on BSD should be command instead of cmd.)
  2. Check for $BASH_VERSION, $ZSH_VERSION, and other shell-specific variables.
  3. Check $SHELL; this is a last resort, as it specifies your default shell and not necessarily the current shell.

Several ways, from most to least reliable (and most-to-least "heavy"):

  1. ps -p$$ -ocmd=. (On Solaris, this may need to be fname instead of cmd.)
  2. Check for $BASH_VERSION, $ZSH_VERSION, and other shell-specific variables.
  3. Check $SHELL; this is a last resort, as it specifies your default shell and not necessarily the current shell.

Several ways, from most to least reliable (and most-to-least "heavy"):

  1. ps -p$$ -ocmd=. (On Solaris, this may need to be fname instead of cmd. On OSX and on BSD should be command instead of cmd.)
  2. Check for $BASH_VERSION, $ZSH_VERSION, and other shell-specific variables.
  3. Check $SHELL; this is a last resort, as it specifies your default shell and not necessarily the current shell.
1
source | link

Several ways, from most to least reliable (and most-to-least "heavy"):

  1. ps -p$$ -ocmd=. (On Solaris, this may need to be fname instead of cmd.)
  2. Check for $BASH_VERSION, $ZSH_VERSION, and other shell-specific variables.
  3. Check $SHELL; this is a last resort, as it specifies your default shell and not necessarily the current shell.