3 added 39 characters in body
source | link

A mix of all the other answers, compatible with Mac (comm), Solaris (fname) and Linux (cmd):

ps -p$$ -o cmd="",comm="",fname="" 2>/dev/null | sed 's/^-//' | grep -oE '\w+' | head -n1

A mix of all the other answers, compatible with Mac and Linux:

ps -p$$ -o cmd="",comm="" 2>/dev/null | sed 's/^-//' | grep -oE '\w+' | head -n1

A mix of all the other answers, compatible with Mac (comm), Solaris (fname) and Linux (cmd):

ps -p$$ -o cmd="",comm="",fname="" 2>/dev/null | sed 's/^-//' | grep -oE '\w+' | head -n1
2 added 27 characters in body
source | link

A mix of all the other answers, compatible with Mac and Linux:

ps -p$$ -o com,cmdcmd="",comm="" 2>/dev/null | sed 's/^-//' | grep -oE '\w+' | head -n1

A mix of all the other answers, compatible with Mac and Linux:

ps -p$$ -o com,cmd,comm="" 2>/dev/null | sed 's/^-//'

A mix of all the other answers, compatible with Mac and Linux:

ps -p$$ -o cmd="",comm="" 2>/dev/null | sed 's/^-//' | grep -oE '\w+' | head -n1
1
source | link

A mix of all the other answers, compatible with Mac and Linux:

ps -p$$ -o com,cmd,comm="" 2>/dev/null | sed 's/^-//'