bug#15926: RFE: unlink command already uses 'unlink' call; make 'rm' use (original) (raw)


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


From: Bernhard Voelker
Subject: bug#15926: RFE: unlink command already uses 'unlink' call; make 'rm' use 'remove' call
Date: Thu, 21 Nov 2013 01:03:15 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130329 Thunderbird/17.0.5

On 11/20/2013 02:44 PM, Eric Blake wrote:

On 11/19/2013 11:45 PM, Bernhard Voelker wrote: > Maybe "cannot remove directory" is a bit weak - it's more like > "refusing to remove dot|dot-dot|root directory".

Indeed, a clearer error message would be possible.

What about the following?

$ src/rm -r src/. src/rm: refusing to remove '.' or '..' directory: skipping 'src/.'

I didn't want to explicitly mention POSIX here ... it's just to clarify that rm(1) does not swallow errors from the kernel like EPERM, etc.

The texinfo file is enhanced in the patch below, too.

Have a nice day, Berny

From f85ec85852ea62e4fe4510044ffb4b31880a6b7c Mon Sep 17 00:00:00 2001 From: Bernhard Voelker <address@hidden> Date: Thu, 21 Nov 2013 00:47:36 +0100 Subject: [PATCH] doc: enhance diagnostic when rm skips "." or ".." arguments

The error diagnostic "rm: cannot remove directory: '.'" does not give the user a hint for the reason. Issue a clearer error message.


doc/coreutils.texi | 3 ++- src/remove.c | 12 ++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/doc/coreutils.texi b/doc/coreutils.texi index 035f2e6..64713dc 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi @@ -9281,7 +9281,8 @@ the @option{-f} or @option{--force} option is not given, or the If the response is not affirmative, the file is skipped.

Any attempt to remove a file whose last file name component is address@hidden or @file{..} is rejected without any prompting. address@hidden or @file{..} is rejected without any prompting, as mandated +by POSIX.

@emph{Warning}: If you use @command{rm} to remove a file, it is usually possible to recover the contents of that file. If you want more assurance diff --git a/src/remove.c b/src/remove.c index cdbbec5..3d386cf 100644 --- a/src/remove.c +++ b/src/remove.c @@ -437,17 +437,21 @@ rm_fts (FTS *fts, FTSENT *ent, struct rm_options const x) / Perform checks that can apply only for command-line arguments. */ if (ent->fts_level == FTS_ROOTLEVEL) {

-- 1.8.3.1