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: Todd C. Miller
Subject: Re: bash doesn't run as a login when when -c specified
Date: Tue, 28 Jun 2011 08:35:02 -0400

Thanks for the speedy reply.  I checked the RedHat src rpm and they
do enable NON_INTERACTIVE_LOGIN_SHELLS which explains why the
versions I built myself behaved differently from the system bash.

 - todd

On Mon, 27 Jun 2011 22:31:55 EDT, Chet Ramey wrote:

> On 6/27/11 11:28 AM, Todd.Miller@courtesan.com 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    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/
> 




reply via email to

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