Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

pwd isn't being updated when moved

5 views
Skip to first unread message

Eddie

unread,
Sep 11, 2006, 10:41:02 AM9/11/06
to bug-...@gnu.org
Machine: i686
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i686'
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i686-redhat-linux-gnu'
-DCONF_VENDOR='redhat' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash'
-DSHELL -DHAVE_CONFIG_H -I. -I. -I./include -I./lib
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -pipe -m32 -march=i386
-mtune=pentium4
uname output: Linux syn.walla.co.il 2.6.9-22.EL #1 Sat Oct 8 17:48:27
CDT 2005 i686 i686 i386 GNU/Linux
Machine Type: i686-redhat-linux-gnu

Bash Version: 3.0
Patch Level: 15
Release Status: release

Description:
when user is in window one in some directory, and from window
two that directory is moved to another
location (or name), the pwd in the first window isn't being
updated and when user tries to access a file
without using full path, it gets the file that was in the
original directory even thought it was moved.

Repeat-By:
in window 1:
-------------

mkdit ~/test;
cd ~/test;
echo "hey" > file;

cat file;
-- "hey"

------------------

in window 2:
------------
mv ~/test ~/test.old
mkdir ~/test
echo "bye" > file;
cat file;
-- "bye";

------------------

in window 1:
------------
cat file;
-- "hey" (even thought ~/test/file contains now "bye")
cat `pwd`/file;
-- "bye" (it's ok using full path)

------------------------

also:

[quatrix@syn test]$ ll
total 0
-rw-rw-r-- 1 quatrix quatrix 0 Sep 11 17:39 go
-rw-rw-r-- 1 quatrix quatrix 0 Sep 11 17:39 hey
-rw-rw-r-- 1 quatrix quatrix 0 Sep 11 17:39 ho
-rw-rw-r-- 1 quatrix quatrix 0 Sep 11 17:39 lets
[quatrix@syn test]$ ll `pwd`
total 0
-rw-rw-r-- 1 quatrix quatrix 0 Sep 11 17:40 a
-rw-rw-r-- 1 quatrix quatrix 0 Sep 11 17:40 b
-rw-rw-r-- 1 quatrix quatrix 0 Sep 11 17:40 c

--------------------------------


P.S. i checked for this bug in csh, just to make sure it's not a
file system glich, and
in csh when one moves a directory, a user who's in that
directory gets its 'pwd' changed to the new value;

Chet Ramey

unread,
Sep 11, 2006, 10:54:47 PM9/11/06
to Eddie, bug-...@gnu.org, ch...@case.edu
Eddie wrote:
> Machine: i686
> OS: linux-gnu
> Compiler: gcc
> Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i686'
> -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i686-redhat-linux-gnu'
> -DCONF_VENDOR='redhat' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash'
> -DSHELL -DHAVE_CONFIG_H -I. -I. -I./include -I./lib
> -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -pipe -m32 -march=i386
> -mtune=pentium4
> uname output: Linux syn.walla.co.il 2.6.9-22.EL #1 Sat Oct 8 17:48:27
> CDT 2005 i686 i686 i386 GNU/Linux
> Machine Type: i686-redhat-linux-gnu
>
> Bash Version: 3.0
> Patch Level: 15
> Release Status: release
>
> Description:
> when user is in window one in some directory, and from window two
> that directory is moved to another
> location (or name), the pwd in the first window isn't being
> updated and when user tries to access a file
> without using full path, it gets the file that was in the
> original directory even thought it was moved.

Since there's no notification given to a process when its current working
directory is renamed, shells that cache the current directory in $PWD and
make pwd essentially `echo $PWD' can get tripped up by pathological
conditions like this.

You have a couple of choices: alias pwd to "pwd -P" so you always get the
physical path; run in posix mode, where the shell checks its cached value
against `.' before displaying it; or use /bin/pwd like csh.

Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
Live Strong. No day but today.
Chet Ramey, ITS, CWRU ch...@case.edu http://cnswww.cns.cwru.edu/~chet/


0 new messages