Removing `pwd` (was Re: VERY SERIOUS rmdir bug)

Chris Torek chris at umcp-cs.UUCP
Thu Aug 21 02:56:26 AEST 1986


In (I guess) <-932157 at homer> someone writes:
>>try this one:
>>	$ mkdir foo
>>	$ cd foo
>>	$ (cd ..; rmdir foo)
>>then try
>>	$ pwd
>>	$ ls
>>	$ cd ..
>>this is great fun!

In article <236 at bsdpkh.UUCP> latham at bsdpkh.UUCP (Ken Latham) writes:
>..... NO it's SHELL !!!!
>
>these two are "BUGS" in shell not 'RMDIR' ( not technically though )
					     ----------------------
(I guess that this means `these two are not, technically speaking, bugs.')

Indeed, these are not bugs in anything.  Removing a directory
involves erasing `.' and `..', then unlinking the directory: but
unlinking any open file does not in fact get rid of it until it is
closed; and the current directory of any process is effectively
`open'.  The `.' and `..' entries for `foo' above are indeed gone,
but the (now entirely empty) directory continues to exist until
you chdir out of it.  `ls' and `pwd' are unable to open `.' (since
it no longer exists), and `chdir' cannot find `..'; but `cd $HOME'
works quite well.

>When you remove the cwd from inside shell, you strand yourself there.

Not at all: you may use any absolute path name.  Only relative names
fail; for relative names are dependent upon `.' and `..'.

>Ksh does not have these problems.

Some do not consider this a problem . . . !  (Ksh obviously cleverly
translates `cd ..' into `well, I was in /usr/bar/foo, so I should
go to /usr/bar'.  The C shell does similar tricks at times.  They
are sometimes useful, sometimes annoying.)
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
UUCP:	seismo!umcp-cs!chris
CSNet:	chris at umcp-cs		ARPA:	chris at mimsy.umd.edu



More information about the Comp.unix.wizards mailing list