[svlug] Removing current working directory

Karsten M. Self kmself at ix.netcom.com
Sun Jan 6 23:38:02 PST 2002


on Mon, Jan 07, 2002 at 12:49:11AM -0500, S (step1b at cyberspace.org) wrote:
>  As far as I know, one cannot delete the present working
>  directory.  I observed the following strange behaviour: (rh7.1)
>  
>  [root at localhost root]# mkdir testdir
>  [root at localhost root]# cd testdir
>  [root at localhost testdir]# rmdir .
>  rmdir: `.': Invalid argument
>  [root at localhost testdir]# rmdir ../testdir/
>  [root at localhost testdir]#
> [root at localhost testdir]# man rmdir
>  shell-init: could not get current directory: getcwd: cannot access parent
>  directories: No such file or directory
>  shell-init: could not get current directory: getcwd: cannot access parent
>  directories: No such file or directory
>  shell-init: could not get current directory: getcwd: cannot access parent
>  directories: No such file or directory
>  chdir: could not get current directory: getcwd: cannot access parent
>  directories: No such file or directory
>  RMDIR(1)                       FSF                       RMDIR(1)
>  ..
>  ..
>  q
> [root at localhost testdir]# cd
> [root at localhost root]# man rmdir
>  --doesnt crib here --
>  
>  Any comments?

Yes, you can do that.

rm and rmdir rm refuse to remove '.' or '..'.  They'll happily remove a
specified directory by absolute or relative reference, even if that's
$PWD.  In fact:

    $ cd /tmp
    $ mkdir bar
    $ cd bar
    $ rmdir $PWD

...succeeds.

As usual, GNU/Linux provides you enough rope to hang yourself, and a few
extra feet, just to make sure.  It then pretends that the rope won't
actually reach the gallows, but, well, that's not really true.

Peace.

-- 
Karsten M. Self <kmself at ix.netcom.com>        http://kmself.home.netcom.com/
 What part of "Gestalt" don't you understand?              Home of the brave
  http://gestalt-system.sourceforge.net/                    Land of the free
We freed Dmitry! Boycott Adobe! Repeal the DMCA! http://www.freesklyarov.org
Geek for Hire                      http://kmself.home.netcom.com/resume.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 232 bytes
Desc: not available
Url : http://lists.svlug.org/archives/svlug/attachments/20020106/f1bb976e/attachment.bin


More information about the svlug mailing list