I guess gnome-terminal might have modified
PATH environ variable when invoking shell.
$HOME/.local/bin:$HOME/bin will always be appended to
I did the following experiment to demonstrate this:
- Open a gnome-terminal
- traverse through "Edit" -> "Preference" -> "Profiles" and "Edit" your current profile (which is "Unamed" for me)
- Under the "Command" tab, check "Run a custom command instead of my shell" and
fill in the following input area with
sh. In this way,
bashshould be called in
sh-way and it's not a login shell.
- To further make sure the
$HOME/.bashrcdoesn't get sourced, we rename these files temporarily. (Actually, these files should NOT get sourced already, as we are invoking a non-login
Now, open a new gnome-terminal window and run
echo $PATH. Here is what I got:
I don't understand why the last two path appeared in
Based on this fact, I think the following possible explanations exists:
PATHis inherited from parent process, which in this case is the
PATHis modifed in some script that is sourced mysteriously by
shat some point.
PATHis modifed when gnome-terminal-server forks off the subprocess.
Now I think I have ruled out the #1 and the #2 possibilties:
$PPIDis the PID of
gnome-terminal-servershows that its
/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin, which does not contain what we are looking for.
shwe have just opened, run
export -n PATHand
sh -x, I can see nothing get sourced during the init process of this new
sh. And its
Which leaves me the last possibility.
Did I missed something? Is gnome-terminal the culprit for the mysteriously modified
I just tried
sh -x as the custom command. Upon opening gonme-terminal, I didn't see anything get sourced. But,
echo $PATH says that
$HOME/bin are there.
Here are distro related info:
- Fedora 23 (4.4.8-300.fc23.x86_64)
- bash version 4.3.42(1)-release (x86_64-redhat-linux-gnu)
I just tried:
echo "$PATH"at the very beginning of
- opening gnome-terminal with bash in the default non-login shell mode, with custom command
Based on debug ouput, I observed that the
~/.bashrc is the starting point of script sourcing. But the
$HOME/bin are already there in
PATH even before that.