[26328] in Athena Bugs
linux 9.3.18: bashrc
daemon@ATHENA.MIT.EDU (Jacob Morzinski)
Mon Jan 24 23:48:08 2005
Message-Id: <200501250447.j0P4lXPj015756@opus.mit.edu>
To: bugs@mit.edu
Date: Mon, 24 Jan 2005 23:47:33 -0500
From: "Jacob Morzinski" <jmorzins@mit.edu>
cc: jmorzins@mit.edu
Errors-To: bugs-bounces@mit.edu
System name: opus.mit.edu
Type and version: i686 9.3.18 (with mkserv)
Display type: nVidia Corporation NV5 [RIVA TNT2/TNT2 Pro] (rev 15)
Shell: /bin/athena/bash
Window manager: sawfish
What were you trying to do?
Use bash, $PWD, and $DIRSTACK.
What's wrong:
When starting a bash login shell, the system bashrc sets
HOME to be equal to the full path name of the current
directory, but does not if change any other bash
references to the current directory.
In particular, it does not change PWD, and does not
change DIRSTACK.
This causes minor annoyances when using Emacs, or when
using pushd and popd in bash.
In emacs, instead of C-x C-f giving the user a prompt
that begins with "~/", the prompt begins with
"/mit/jmorzins" (your username here). This is because
emacs compares PWD and HOME, notices that they differ,
and so emacs does not use "~" in the prompt.
In bash, since $HOME changed but $PWD and ${DIRSTACK[0]}
did not, commands that compare HOME to PWD will fail at
the beginning of a user's log in session. In particular,
"dirs -v" shows "/mit/jmorzins" as the starting
directory for the current dotfiles, which I think is the
exact issue that the x=`/bin/pwd` commands was designed
to prevent.
What should have happened:
If the system bashrc script changes HOME, it should "cd"
the user into the new HOME, so that all appropriate shell
variables are updated to know of the new working directory.
Adding one line to the system bashrc is sufficient for
this change. Add a "cd $HOME". This will update PWD,
which will make emacs do the right thing when a user
types C-x C-f, and will also update DIRSTACK, causing
bash's "dirs -v" command to correcly list "~" as the
starting location.
If a "cd" is undesirable, I think you can get the same
effect by setting PWD and DIRSTACK[0] by hand.
Please describe any relevant documentation references:
Here's a patch for the bashrc:
*** bashrc.orig 2005-01-24 23:42:46.000000000 -0500
--- bashrc 2005-01-24 23:42:18.000000000 -0500
***************
*** 125,130 ****
--- 125,131 ----
x=`/bin/pwd`
if [ -n "$x" ]; then
export HOME=$x
+ cd "$HOME"
fi
unset x
Thank you,
Jacob Morzinski jmorzins@mit.edu