bug-bash
[Top][All Lists]
Advanced

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

Re: bash doesn't run as a login when when -c specified


From: Chet Ramey
Subject: Re: bash doesn't run as a login when when -c specified
Date: Mon, 27 Jun 2011 22:31:55 -0400
User-agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.17) Gecko/20110414 Lightning/1.0b2 Thunderbird/3.1.10

On 6/27/11 11:28 AM, address@hidden wrote:

> Machine Type: x86_64-unknown-openbsd4.9
> 
> Bash Version: 4.2
> Patch Level: 10
> Release Status: release
> 
> Description:
>         Newer versions of bash appear to ignore the '-' in argv[0]
>         when the "-c" option is specified.  That is, for:
>           char *argv[] = { "-bash", "-c", "id", NULL };
>       bash used to run as a login shell and source .bash_profile.
>         I've verified that bash 3.00.15 behaves as expected but
>         bash 3.2 and 4.2 require that the "-l" option be specified
>         even though argv[0] indicates that it should be a login
>         shell.  Is this change in historical behavior intentional?

Yes.  It's a compile-time option (NON_INTERACTIVE_LOGIN_SHELLS, which is
off by default) and has been that way for almost 15 years.  The change
log says that option was added before bash-2.02; the code is the same in
bash-3.0.  The thinking was that allowing non-interactive login shells
that sourced startup files intended to be run when interactive (e.g.,
.bash_profile) caused more harm than good, and that non-interactive
shells shouldn't be running any startup files in general.

>         All other Borne-type shells I've tried have the historical
>         behavior.

Bash behaves that way when run in Posix mode.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/



reply via email to

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