bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: login shell or not?


From: Chet Ramey
Subject: Re: login shell or not?
Date: Mon, 12 Feb 2007 11:49:44 -0500
User-agent: Thunderbird 1.5.0.9 (Macintosh/20061207)

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    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]