[Top][All Lists]

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

Re: Avoid sourcing bashrc when connected to sockets

From: Chet Ramey
Subject: Re: Avoid sourcing bashrc when connected to sockets
Date: Mon, 14 Feb 2022 11:11:52 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.6.0

On 2/13/22 2:55 PM, Andrew Gregory wrote:
The pacman package manager runs install scripts by forking and invoking a
compile-time configured shell by calling "<shell> -c '. <path-to-script>;
<operation> <args>'", e.g. "bash -c '. /tmp/.INSTALL; pre_install pacman'".  A
while back we switched from using pipes to sockets to communicate with the fork
in order to avoid SIGPIPE problems.  Unfortunately, this makes bash think it's
being run under rsh/ssh and it now reads ~/.bashrc, which can break scripts.
Can the rsh/ssh check be modified to ignore this case?

How do you tell "this case" from others?

You could start bash with the SHLVL environment variable set to something
greater than 2. That will inhibit sourcing bashrc even if bash thinks it
was run by ssh or stdin is a socket. Make sure to unset BASH_ENV as well.

You might also want to tell your vendor about this, since they built bash
with the non-standard option that enables this behavior.

``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU

reply via email to

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