SUMMARY: $SHELL Reports Incorrectly

From: Sumair Mahmood <Sumair.Mahmood_at_qlogic.com>
Date: Tue Jun 04 2002 - 19:02:23 EDT
QUESTION:
=========
Why does `echo $SHELL` "lie" when you change shells?

> My default shell is 'csh'
mysystem{root} 2 : echo $SHELL
/bin/csh
> No problems here

> If I use 'bash', $SHELL still indicates 'csh'
mysystem{root} 3 : bash
bash-2.03# echo $SHELL
/bin/csh

> If I use 'tcsh', $SHELL also indicates 'csh'
bash-2.03# exit
exit
mysystem{root} 4 : tcsh
mysystem{root} 1 : echo $SHELL
/bin/csh

ANSWER:
========

This is a perfectly normal behavior.   The value of $SHELL
is not set by the shell; it's passed through as part of your
environment from the process that creates your login and
launches your shell (for instance, 'login', 'telnetd' or 'sshd'):

# man login
...
      The basic environment is initialized to:

           HOME=your-login-directory
           LOGNAME=your-login-name
           PATH=/usr/bin:
           SHELL=last-field-of-passwd-entry
           MAIL=/var/mail/TZ=timezone-specification
...

Since your login shell is 'csh', $SHELL is set to /bin/csh
when you first login, and remains untouched no matter
what other shell is invoked afterward.  Therefore $SHELL
is your login shell NOT your current shell.

To find your current shell in Solaris, try:
	# echo $0
or
	# /bin/ps -p $$
	# /bin/ps -p $$ -o comm=
etc.

[ With sincere thanks to Sanjiv Bhatia, Wesley Wannemacher,
 Fabrice Guerini, Amir Mahajan, Michael Maciolek, Kevin
 Inscoe, and everyone else who responded!]
_______________________________________________
sunmanagers mailing list
sunmanagers@sunmanagers.org
http://www.sunmanagers.org/mailman/listinfo/sunmanagers
Received on Tue Jun 4 19:09:52 2002

This archive was generated by hypermail 2.1.8 : Thu Mar 03 2016 - 06:42:46 EST