Bug 1286767 - bash blocks $HOME/.profile
bash blocks $HOME/.profile
Status: CLOSED NOTABUG
Product: Fedora
Classification: Fedora
Component: bash (Show other bugs)
rawhide
All Linux
unspecified Severity high
: ---
: ---
Assigned To: Ondrej Oprala
Fedora Extras Quality Assurance
: Reopened
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2015-11-30 11:50 EST by poma
Modified: 2016-01-31 21:10 EST (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2015-12-02 02:10:51 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Includes sourcing ~/.profile within ~/.bash_profile for user specific Xorg/Wayland related environment variables (511 bytes, patch)
2015-12-01 07:18 EST, poma
no flags Details | Diff

  None (edit)
Description poma 2015-11-30 11:50:45 EST
Description of problem:
$HOME/.bashrc and $HOME/.bash_profile block the use of $HOME/.profile

Version-Release number of selected component (if applicable):
bash-4.3.42-1.fc24.x86_64

How reproducible:
101%

Steps to Reproduce:
1. Create "system-wide" envvar
2. Create "per-user" envvar in contrast to "system-wide" envvar
3. See "Additional info" for details

Actual results:
"per-user" envvar -inapplicable-

Expected results:
"per-user" envvar -applicable-

Additional info:

 = 1st X-session =

$ printenv | grep ENVVAR
ENVVAR=system-wide

$ cat /etc/profile.d/envvar.sh 
export ENVVAR=system-wide

$ echo 'ENVVAR=per-user' > ~/.profile

~~~~~~~~~~~~~~~~~~

 = 2nd X-session =

$ printenv | grep ENVVAR
ENVVAR=system-wide

$ cat /etc/profile.d/envvar.sh 
export ENVVAR=system-wide

$ cat ~/.profile
ENVVAR=per-user

$ rm ~/.bashrc ~/.bash_profile

~~~~~~~~~~~~~~~~~~

 = 3rd X-session =

$ env | grep ENVVAR
ENVVAR=per-user

$ cat /etc/profile.d/envvar.sh 
export ENVVAR=system-wide

$ cat ~/.profile
ENVVAR=per-user

$ ls ~/.bashrc ~/.bash_profile
ls: cannot access /home/liveuser/.bashrc: No such file or directory
ls: cannot access /home/liveuser/.bash_profile: No such file or directory
Comment 1 Ondrej Oprala 2015-12-01 01:06:56 EST
An excerpt from the bash manpage:
"...it[bash]  looks  for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable."

So $HOME/.bash_profile "covering" $HOME/.profile is the intended documented behaviour.
Comment 2 poma 2015-12-01 07:08:52 EST
Just because something is documented, does not necessarily mean it is wise enough in certain circumstances.

See:
http://superuser.com/questions/789448/choosing-between-bashrc-profile-bash-profile-etc

<quote>

TL;DR: < 98 >

~/.bash_profile should be super-simple and just load .profile and .bashrc (in that order)
~/.profile has the stuff NOT specifically related to bash, such as environment variables (PATH and friends)
~/.bashrc has anything you'd want at an interactive command line. Command prompt, EDITOR variable, bash aliases for my use

A few other notes:

Anything that should be available to graphical applications OR to sh (or bash invoked as sh) MUST be in ~/.profile
~/.bashrc must not output anything
Anything that should be available only to login shells should go in ~/.profile
Ensure that ~/.bash_login does not exist.

...

</quote>
Comment 3 poma 2015-12-01 07:18 EST
Created attachment 1100857 [details]
Includes sourcing ~/.profile within ~/.bash_profile for user specific Xorg/Wayland related environment variables


Living Example

~~~~~~~~~~~~~~~~~

= 1st X-session =

$ bash --login 

$ printenv | grep XFWM4
XFWM4_USE_PRESENT=1

$ cat /etc/profile.d/xorg-wayland.sh 
# System-wide Xorg/Wayland related environment variables
#
# Xfwm4 non-default XPresent VSync
export XFWM4_USE_PRESENT=1

$ LIBGL_DEBUG=verbose vblank_mode=0 glxgears
...
7211 frames in 5.0 seconds = 1442.051 FPS
7307 frames in 5.0 seconds = 1461.165 FPS
7324 frames in 5.0 seconds = 1464.722 FPS
7320 frames in 5.0 seconds = 1463.992 FPS
7326 frames in 5.0 seconds = 1464.974 FPS
^C

~~~~~~~~~~~~~~~~~

= 2nd X-session =

$ bash --login

$ printenv | grep XFWM4
XFWM4_USE_PRESENT=0

$ cat /etc/profile.d/xorg-wayland.sh 
# System-wide Xorg/Wayland related environment variables
#
# Xfwm4 non-default XPresent VSync
export XFWM4_USE_PRESENT=1

$ cat ~/.profile
# User specific Xorg/Wayland related environment variables
#
# Xfwm4 default GLX VSync
export XFWM4_USE_PRESENT=0

$ cat ~/.bash_profile 
...
# User specific Xorg/Wayland related environment variables
if [ -f ~/.profile ]; then
        . ~/.profile
fi

$ LIBGL_DEBUG=verbose vblank_mode=0 glxgears
...
5715 frames in 5.0 seconds = 1142.826 FPS
5753 frames in 5.0 seconds = 1150.397 FPS
5748 frames in 5.0 seconds = 1149.595 FPS
5726 frames in 5.0 seconds = 1145.072 FPS
5744 frames in 5.0 seconds = 1148.747 FPS
^C

~~~~~~~~~~~~~~~~~

Ref.
"compositor: add envvar for Xpresent"
http://git.xfce.org/xfce/xfwm4/commit/?id=2321afb
Comment 4 Olivier Fourdan 2015-12-01 11:20:50 EST
Not sure why I am copied on this bug, but the status transition from "closed" to "modified" does not seem right to me.
Comment 5 Ondrej Oprala 2015-12-02 02:10:51 EST
I appreciate your attention to detail. However, still, this is not a bug, this is the intended behaviour and as such should be discussed on the bash mailing list and possibly changed upstream first, not in one linux distro.

Note You need to log in before you can comment on or make changes to this bug.