bug-bash
[Top][All Lists]
Advanced

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

Re: Use of --rcfile does not preclude read of /etc/bash.bashrc


From: Chet Ramey
Subject: Re: Use of --rcfile does not preclude read of /etc/bash.bashrc
Date: Mon, 8 Jan 2018 10:24:08 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.5.2

On 1/6/18 8:14 AM, Nat! wrote:
> I tried to come up with a workaround, but I couldn't find any.
> 
> Basically what I do:
> 
>     env -i bash --norc --noprofile
> 
> 
> This gives me an interactive shell, with a very clean environment (even no
> PATH), that does not contain system specify "surprises".
> This works.
> 
> But what I really want is to set up a custom environment before going
> interactive.
> 
>     env -i bash --norc --noprofile --rcfile custom.sh
> 
> This doesn't work, because --norc (IMO) incorrectly preempts the --rcfile
> use, where's the point ?

It's not incorrect; --norc is intended to suppress execution of the
interactive shell startup files, even if you specify another file to not
execute.

You could use $ENV, but that's only effective for shells started in
Posix mode.

> 
> The command
> 
>     env -i bash --noprofile --rcfile x.sh
> 
> does work to my satisfactions on systems, that do not enable SYS_BASHRC (OS
> X).
> 
> So if --rcfile was a feature earlier than SYS_BASHRC (2.05), it's a bona
> fide regression.

It's not a regression. The sole intent of SYS_BASHRC was to allow system
administrators who wanted a file sourced before the user's interactive
shell startup file (e.g., to make sure that some environment variables were
set) to specify one. It's not intended to be overridden, and it's executed
under the same circumstances as the user's bashrc file.

(SYS_BASHRC was inserted in August, 1995 and made its first public
appearance in bash-2.0. Discussion started a few months prior.)

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



reply via email to

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