|
Home > Archive > Unix questions > December 2006 > Two xterms changing same directory
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Two xterms changing same directory
|
|
| achambers.home@googlemail.com 2006-12-05, 7:32 am |
| Hi All,
I came across some strange behaviour today. I don't think its a bug
but I wonder how many other people
have noticed.
In one xterm, we have the following session
$ pwd
/home/andy/devel/test/one
....and in another, we have
$ pwd
/home/andy/devel/test
$ mv one one.old
....back to the first
$ pwd
/home/andy/devel/test/one
....even though in the second
$ ls
one.old
Wouldn't it be better if pwd recognized that the current directory had
been changed by some other
process? I was bitten by this whilst working with a few xterms open.
In one, I moved my project
directory to a backup location, deleted the original, then checked out
the project again using cvs.
In another, I made some new changes, and couldn't work out why they
weren't coming through in
the application. The changes were being made to the backed up version
even though the shell
told me I was working in the newly checked out directory.
I'm using Linux (Debian Etch). Do any other unices handle this
situation differently?
| |
| Stephane CHAZELAS 2006-12-05, 7:32 am |
| 2006-12-5, 04:31(-08), achambers.home@googlemail.com:
> Hi All,
>
> I came across some strange behaviour today. I don't think its a bug
> but I wonder how many other people
> have noticed.
>
> In one xterm, we have the following session
>
> $ pwd
> /home/andy/devel/test/one
>
>
> ...and in another, we have
> $ pwd
> /home/andy/devel/test
> $ mv one one.old
>
>
> ...back to the first
> $ pwd
> /home/andy/devel/test/one
[...]
Use pwd -P instead. pwd is pwd -L, it's a logical current
directory built /logically/ every time you use cd without -P.
Like: cd /foo; cd bar will set $PWD (or the output of pwd/pwd
-L) to /foo/bar even if either of /foo or bar is a symlink.
Similarly cd .., doesn't to chdir("..") it strips off one
trailing component of $PWD and goes to that directory.
You should be able to do "cd -P ." to update the value of $PWD
to the absolute value of the current directory.
--
Stéphane
|
|
|
|
|