(I know it's late, but hoping someone could use it.)
I've had great results with this combination:
ps -p $$ | awk '$1 != "PID" {print $(NF)}'
ps -p $$ | awk '$1 != "PID" {print $(NF)}' Edit 1: On Tru64 (OSF/1), the output has parentheses around the shell. Tack on tr -d '()'tr -d '()' to remove them.
ps -p $$ | awk '$1 != "PID" {print $(NF)}' | tr -d '()'
ps -p $$ | awk '$1 != "PID" {print $(NF)}' | tr -d '()' Appears to works on all shells, on Solaris 10 and RHEL 5.7 / 6.4. Didn't test other distros such as Debian, Ubuntu, or Mint, but I would think they should all work the same; I also have no idea if FreeBSD would work.
