Last modified: 2014-08-17 17:44:24 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T52249, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 50249 - 'become' doesn't load ~/.bashrc
'become' doesn't load ~/.bashrc
Status: RESOLVED INVALID
Product: Wikimedia Labs
Classification: Unclassified
tools (Other open bugs)
unspecified
All All
: Unprioritized normal
: ---
Assigned To: Marc A. Pelletier
:
Depends on:
Blocks: 66868
  Show dependency treegraph
 
Reported: 2013-06-26 17:59 UTC by Roan Kattouw
Modified: 2014-08-17 17:44 UTC (History)
0 users

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Roan Kattouw 2013-06-26 17:59:54 UTC
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
# Shortcuts
alias ..='cd ..'
alias ll='ls -ahlF --color=auto'
alias l='ll'

# Environment
export PATH=$HOME/bin:$PATH;

local-visualeditor@tools-login:~$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin
local-visualeditor@tools-login:~$ . ~/.bashrc
local-visualeditor@tools-login:~$ echo $PATH
/data/project/visualeditor/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin

Adding $HOME/bin to $PATH would probably be a nice thing to do in general.
Comment 1 Marc A. Pelletier 2013-06-26 18:06:40 UTC
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.

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


Navigation
Links