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

Submitter:  None
Submitted:  Mon 17 Mar 2008 10:16:03 PM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  Invalid
Privacy:  Public Assigned 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>
Group 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>
Group 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

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2008-03-18 meyering Open/ClosedOpen Closed
    2008-03-18 meyering StatusNone Invalid

    Back to the top

    Powered by Savane 3.13-bb6a.
    Corresponding source code