Page MenuHomePhabricator

'become' doesn't load ~/.bashrc
Closed, InvalidPublic


When you use 'become' to log into a shared account, ~/.bashrc isn't run.

catrope@tools-login:~$ become visualeditor
local-visualeditor@tools-login:~$ cat ~/.bashrc


alias ..='cd ..'
alias ll='ls -ahlF --color=auto'
alias l='ll'


export PATH=$HOME/bin:$PATH;

local-visualeditor@tools-login:~$ echo $PATH
local-visualeditor@tools-login:~$ . ~/.bashrc
local-visualeditor@tools-login:~$ echo $PATH

Adding $HOME/bin to $PATH would probably be a nice thing to do in general.

Version: unspecified
Severity: normal



Event Timeline

bzimport raised the priority of this task from to Needs Triage.Nov 22 2014, 2:08 AM
bzimport added a project: Toolforge.
bzimport set Reference to bz50249.

Works as designed.

become, through sudo, creates an interactive login shell. To quote from the bash info page:

" When Bash is invoked as an interactive login shell, or as a

non-interactive shell with the `--login' option, it first reads and
executes commands from the file `/etc/profile', if that file exists.
After reading that file, it 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."

A thing many users may want to do to simplify things is to have a ~/.profile that sources ~/.bashrc (in addition or instead of login-specific behaviour) so that the latter gets sourced regardless of how the shell was invoked.