bugGNU Core Utilities - Bugs: bug #22646, RFE: -I option for rm: prompt once...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #22646: RFE: -I option for rm: prompt once on directories

Submitted by:  None
Submitted on:  Mon 17 Mar 2008 10:16:03 PM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: NoneStatus: Invalid
Privacy: PublicAssigned to: None
Open/Closed: Closed

Tue 18 Mar 2008 07:34:13 AM UTC, comment #3:

Actually, rm -I doesn't do what you want, but maybe it's good enough. As James Youngman pointed out, you don't need to change rm to get the desired behavior. So I'm closing this.

Jim Meyering <meyering>
Project Administrator
Tue 18 Mar 2008 07:26:52 AM UTC, comment #2:

GNU rm already has the -I option, which seems to do what you want.
It was added in coreutils-6.0, released 1.5 years ago:

rm --help says this:

-I prompt once before removing more than three files, or
when removing recursively. Less intrusive than -i,
while still giving protection against most mistakes

Jim Meyering <meyering>
Project Administrator
Mon 17 Mar 2008 10:38:58 PM UTC, comment #1:

No need to change coreutils to get this behaviour:

$ find . -depth -mindepth 1 -type d -ok rm -rf {} \;
< rm ... ./wimpole > ? y
< rm ... ./baz > ? y
< rm ... ./quux > ? y
< rm ... ./foo/bar > ? y
< rm ... ./foo > ? y
< rm ... ./ugh > ? y

James Youngman <jay>
Mon 17 Mar 2008 10:16:03 PM UTC, original submission:

When using "rm -ir *", it can get pretty tedious confirming once for every file, within directories. However, I prefer not to skip the safety-belt entirely by abandoning the -i.

I propose adding a new flag, -I, which behaves in the same way as -i, except that directories are only confirmed once for the whole directory.

Current behaviour:

[~/temp]$ touch a b ; mkdir c ; touch c/{d,e,f,g,h}
[~/temp]$ rm -ir *
rm: remove regular empty file `a'? y
rm: remove regular empty file `b'? y
rm: descend into directory `c'? y
rm: remove regular empty file `c/d'? y
rm: remove regular empty file `c/e'? y
rm: remove regular empty file `c/f'? y
rm: remove regular empty file `c/g'? y
rm: remove regular empty file `c/h'? y
rm: remove directory `c'? y
[~/temp]$

Proposed behaviour:

[~/temp]$ touch a b ; mkdir c ; touch c/{d,e,f,g,h}
[~/temp]$ rm -Ir *
rm: remove regular empty file `a'? y
rm: remove regular empty file `b'? y
rm: remove directory `c' and all its contents? y
[~/temp]$

Personally, I'd then change my .bashrc from "alias rm='rm -i'" to "alias rm='rm -I', though I do realise that this is controversial ;-)

Just an idea - hope you like it. Thanks for all your work on GNU - much appreciated! - Richard

Anonymous

 

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by meyering (Posted a comment)
  • -unavailable- added by jay (Posted a comment)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue 18 Mar 2008 07:34:13 AM UTCmeyeringOpen/ClosedOpen=>Closed
    Tue 18 Mar 2008 07:26:52 AM UTCmeyeringStatusNone=>Invalid

    Back to the top


    Powered by Savane 3.1-cleanup1