login shell or not?

2007-02-12 Thread peter360

In an interative shell, what is the easiest way to tell whether it is a login
shell or not?  Thanks.
-- 
View this message in context: 
http://www.nabble.com/login-shell-or-not--tf3211932.html#a8919535
Sent from the Gnu - Bash mailing list archive at Nabble.com.



___
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash


Re: login shell or not?

2007-02-12 Thread Chet Ramey
peter360 wrote:
 In an interative shell, what is the easiest way to tell whether it is a login
 shell or not?  Thanks.

In sufficiently modern versions of bash (basically anything newer than
bash-2.05), you can test the setting of the `login_shell' shopt variable.
The shell sets it automatically for login shells.

The most portable way to do it, in the sense that it works across multiple
versions of multiple shells, is to set a variable in ~/.bash_profile and
test it later.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
   Live Strong.  No day but today.
Chet Ramey, ITS, CWRU[EMAIL PROTECTED]http://cnswww.cns.cwru.edu/~chet/


___
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash