Bash option "--rcfile" doesn't prevent /etc/bash.bashrc from being executed when launching an interactive shell
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-
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:/
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.
ProblemType: Bug
DistroRelease: Ubuntu 20.04
Package: bash 5.0-6ubuntu1.1
ProcVersionSign
Uname: Linux 5.4.0-53-generic x86_64
ApportVersion: 2.20.11-
Architecture: amd64
CasperMD5CheckR
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.