tags:

views:

59

answers:

4

Is there an easy way by which I can tell which type of unix shell I am in i.e. whether I am in a bash / csh / ksh / tcsh ?

A: 
basename $SHELL

don't know if it works for other shells than bash.

edit this has been asked a few days ago: how-to-determine-the-current-shell-im-working-on

mvds
at times, not reliable.
ghostdog74
+3  A: 
mac:~$ ps
  PID TTY           TIME CMD
  223 ttys000    0:00.33 -bash

obsd:~$ ps
  PID TT  STAT       TIME COMMAND
20038 p0  Ss      0:00.01 -ksh (ksh)
22251 p0  R+      0:00.00 ps

Or just echo $SHELL

Nikolai N Fetissov
I think `$SHELL` is the default shell for the system (or user), which is usually (but not necessarily) the shell that is actually being used at any given moment.
David Zaslavsky
+4  A: 

Try:

echo $0

This often works across a range of shells.

ggg
A: 

Every shell I know of sets the $ variable ($$) to its pid. So...

ps | grep $$
pra