LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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-05-2004, 11:13 PM   #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-05-2004, 11:49 PM   #2
samhob
Member
 
Registered: Jan 2004
Location: Bern, Switzerland
Distribution: Debian
Posts: 72

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

Rep: Reputation: 47
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, 03: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, 04:07 PM   #5
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

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

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


Cheers,
Tink
 
  


Reply



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 07:13 AM
Changing the home directory kyleinc Linux - General 2 02-26-2005 11:54 PM
changing home directory netboy_541 Linux - General 5 09-10-2003 04:09 AM
Changing directory permissions Bagsy Linux - Newbie 1 07-08-2003 05:50 AM
Changing directory pdstatha Programming 1 04-11-2002 07:08 AM

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

All times are GMT -5. The time now is 12:06 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
Open Source Consulting | Domain Registration