Subject: Re: bug#15926: RFE: unlink command already uses 'unlink' call; make 'rm' use 'remove' call

From: Bernhard Voelker <[email-masked]>
Date: Thu, 21 Nov 2013 07:32:23 +0100

On 11/21/2013 01:48 AM, Linda Walsh wrote:
>     Isn't it my computer?  How do I override such a refusal?

That riddle isn't too hard, is it? ;-)

POSIX (and common sense) forbids to remove something ending on ".".
Therefore just use the canonicalized name, e.g.:

  $ mkdir /tmp/xx

  $ cd /tmp/xx

  $ rm -rv .
  rm: refusing to remove ‘.’ or ‘..’ directory: skipping ‘.’

  $ rm -rv "$(pwd -P)"
  removed directory: ‘/tmp/xx’

or alternatively (just the rm invocation):

  $ rm -rv "$(readlink -f .)"
  removed directory: ‘/tmp/xx’

As you were mentioning MS: the above obviously won't probably work
in Cygwin as the underlying (file) system may return EBUSY.

Have a nice day,
Berny