bug-bash
[Top][All Lists]
Advanced

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

Re: bash -c reads /etc/profile despite --noprofile


From: Chet Ramey
Subject: Re: bash -c reads /etc/profile despite --noprofile
Date: Thu, 30 Apr 2015 17:07:15 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:31.0) Gecko/20100101 Thunderbird/31.6.0

On 4/30/15 2:37 PM, Trammell Hudson wrote:

> Bash Version: 4.3
> Patch Level: 30
> Release Status: release
> 
> Description:
> User and system profile files are executed even despite the --noprofile
> or --norc flag to bash since execute_env_file() does not check the
> no_profile global variable.
> 
> Repeat-By:
> PS1="NONE" ./bash --noprofile -c 'echo $PS1'
> 
> Should output NONE, but instead outputs whatever /etc/profile sets it to.
> 
> 
> Fix:
> --- /tmp/bash-4.3.30/shell.c    2014-01-14 13:04:32.000000000 +0000
> +++ ./build/bash-4.3.30/shell.c        2015-04-30 18:25:42.282810228 +0000
> @@ -1010,7 +1010,7 @@
>  {
>    char *fn;
>  
> -  if (env_file && *env_file)
> +  if (no_profile == 0 && env_file && *env_file)
>      {
>        fn = expand_string_unsplit_to_string (env_file, Q_DOUBLE_QUOTES);
>        if (fn && *fn)

That function is only executed if you have BASH_ENV or ENV set, and neither
of those should be subject to the setting of --noprofile.  I suspect you
have BASH_ENV=/etc/profile in your environment since you're invoking bash
as `bash'.

-- 
``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]