Subject: Re: Which shell am I in?
To: Ian Goldby <Ian.Goldby@mail.com>
From: Frederick Bruckman <fb@enteract.com>
List: netbsd-help
Date: 03/24/2001 08:59:35
On Sat, 24 Mar 2001, Ian Goldby wrote:

> There must be an easy answer to this one. How can a shell script (such
> as .profile or .kshrc) find out which shell it is in? I tried using the
> environment variable SHELL, but it often reports the parent process
> shell rather than the actual shell.
>
> E.g. If I start in ksh and echo $SHELL I get /bin/ksh. If I then start
> a sh from  within ksh and echo $SHELL, it's still /bin/ksh.

Try ``if [ $0 = ksh -o $0 = -ksh ]; then ... fi''. Works for me.


Frederick