GNU bug report logs -
#16669
rm: inconsistent 'rm -ir' prompting behavior (POSIX issue)
Previous Next
Full log
View this message in rfc822 format
On 02/06/2014 04:39 PM, Eric Blake wrote:
> On today's Austin Group call, we discussed
> http://austingroupbugs.net/view.php?id=802 regarding 'rm' behavior.
>
> They pointed out that GNU has an optimization not allowed by a strict
> reading of the current standard:
>
> $ mkdir foo
> $ rm -ir foo
> rm: remove directory ‘foo’?
>
> Whether you answer yes or no, the point remains: rm only prompted once
> about removing the empty directory
[snip]
> Conversely, consider:
>
> $ rm -ir foo
> rm: descend into directory ‘foo’? y
> rm: remove regular empty file ‘foo/bar’? n
> rm: remove directory ‘foo’? y
> rm: cannot remove ‘foo’: Directory not empty
>
> Why on earth are we prompting to remove 'foo' when we KNOW it is
> non-empty because the user specifically asked to not remove foo/bar? If
> we can optimize from two prompts down to one for the empty directory
> case, why are we not optimizing and avoiding asking a useless prompt for
> a known non-empty directory?
The different handling could be useful I think.
When we determine there are no files in a dir,
then only one prompt is necessary.
If we determine files are present a separate prompt
is useful to cater for the following sequence
in terminal 1 and terminal 2.
1> $ rm -ir foo
1> rm: descend into directory ‘foo’? y
1> rm: remove regular empty file ‘foo/bar’? n
1> rm: remove directory ‘foo’?
2> mv foo/bar /safe/foo # Handle this unknown file _independently_
1> y
thanks,
Pádraig.
This bug report was last modified 6 years and 240 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.