Bash option "--rcfile" doesn't prevent /etc/bash.bashrc from being executed when launching an interactive shell

Bug #1904552 reported by Taylor Smith
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
bash (Ubuntu)
New
Undecided
Unassigned

Bug Description

Release: Ubuntu 20.04.1 LTS
Bash version: GNU bash, version 5.0.17(1)-release (x86_64-pc-linux-gnu)

From Bash's manual page, this should be the behaviour of the --rcfile option.

<< Execute commands from file instead of the system wide initialization file /etc/bash.bashrc and the standard personal initialization file ~/.bashrc if the shell is interactive (see INVOCATION below). >>

However, that is not the case in practice. Let's consider a short script named "test.sh", which is made up of only one line:

echo "Just testing"

When I open a terminal on my Ubuntu 20.04 machine, and type in the command "bash --rcfile test.sh", I expect my file test.sh to be run instead of /etc/bash.bashrc and ~/.bashrc. However, though my file is run successfully, /etc/bash.bashrc is still run, and is even run before my script. I don't get why (it contradicts the manual page). I noticed that because I introduced an echo command in both /etc/bash.bashrc and ~/.bashrc to monitor their executions.

Upon googling, I noticed I wasn't the first who had such an issue, but no solution was proposed (see the first comment on the accepted answer on this post: https://unix.stackexchange.com/questions/187369/when-is-etc-bash-bashrc-invoked). Finally, it was advised to file a bug.

Hope I clearly described the issue.

P.S. I know this is out of your scope, but just so you know: I had the same issue on Kali-5.6.0-kali2-amd64 (bash 5.0-6)

ProblemType: Bug
DistroRelease: Ubuntu 20.04
Package: bash 5.0-6ubuntu1.1
ProcVersionSignature: Ubuntu 5.4.0-53.59-generic 5.4.65
Uname: Linux 5.4.0-53-generic x86_64
ApportVersion: 2.20.11-0ubuntu27.12
Architecture: amd64
CasperMD5CheckResult: skip
CurrentDesktop: ubuntu:GNOME
Date: Tue Nov 17 13:45:49 2020
InstallationDate: Installed on 2020-04-26 (205 days ago)
InstallationMedia: Ubuntu 20.04 LTS "Focal Fossa" - Release amd64 (20200423)
SourcePackage: bash
UpgradeStatus: No upgrade log present (probably fresh install)
mtime.conffile..etc.bash.bashrc: 2020-11-17T13:26:33.214663

Revision history for this message
Taylor Smith (taylor-81) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.