LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-06-2004, 12:13 AM   #1
fieldmethods
Member
 
Registered: Nov 2002
Location: Maryland
Distribution: redhat 9
Posts: 31

Rep: Reputation: 15
Changing the name of the directory I am in


Hi,

Here's a typescript of something I find... flummoxing.

Code:
$ # Whoa, this is weird. I'm in home sweet home... 
$ pwd
/home/me
$ # I make a directory "baz":
$ mkdir baz
$ cd baz
$ # Okay, here we are.
$ pwd
/home/me/baz
$ # I rename "baz" to "qux" while still in "baz"...
$ mv ../baz ../qux
$ pwd
/home/me/baz
$ # Huh? I thought I was in "qux" now!
$ cd ..
$ cd baz
bash: cd: baz: No such file or directory
$ # Now it's gone?
$ cd qux
$ pwd
/home/me/qux
$ # But "qux" exists. That is weird.
Why does "baz" not show up as "qux" until I reenter the directory?

Cheers,
pat
 
Old 01-06-2004, 12:49 AM   #2
samhob
Member
 
Registered: Jan 2004
Location: Bern, Switzerland
Distribution: Debian
Posts: 72

Rep: Reputation: 15
cd ../qux
 
Old 01-06-2004, 12:50 AM   #3
itsjustme
Senior Member
 
Registered: Mar 2003
Location: Earth
Distribution: Slackware, Ubuntu, Smoothwall
Posts: 1,571

Rep: Reputation: 45
I don't think that's weird.
Though I have no technical data to back me up.
But, probably, since you are in that directory and it's active, it can't just change willy nilly right out from under you. It apparently maintains its identity until the 'session' is released.
 
Old 01-08-2004, 04:43 PM   #4
fieldmethods
Member
 
Registered: Nov 2002
Location: Maryland
Distribution: redhat 9
Posts: 31

Original Poster
Rep: Reputation: 15
Thanks for the replies.


Yeah, I guess "weird" is the wrong word... more like "interesting."

The issue, as I see it, is "when is the name of the current working directory set?" I presume the answer to that is pretty low-level, kernel-level stuff.

Come to think about it, I should reproduce the sequence of commands in different shells, and maybe from a Perl script, to see if I could come up with a different result.

Fun.



Cheers,
Pat
 
Old 01-08-2004, 05:07 PM   #5
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Try a cd . and then look at $PWD ...

Only a cd actually re-evaluates the
current directory and sets PWD...


Cheers,
Tink
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
changing home directory peaceslp Linux - General 1 12-09-2005 08:13 AM
Changing the home directory kyleinc Linux - General 2 02-27-2005 12:54 AM
changing home directory netboy_541 Linux - General 5 09-10-2003 05:09 AM
Changing directory permissions Bagsy Linux - Newbie 1 07-08-2003 06:50 AM
Changing directory pdstatha Programming 1 04-11-2002 08:08 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 09:49 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration