Added rm -rf support

When someone tries to remove a directory without specifying `-rf`, e.g.

    $ mkdir foo
    $ rm foo

the shell refuses to remove the directory with an error:

    rm: foo: is a directory

Instead, you need to use

    $ rm -rf foo

This rule adds fuck support for this:

    $ mkdir foo
    $ rm foo
    rm: foo: is a directory
    $ fuck
    rm -rf foo
This commit is contained in:
Nils Winkler
2015-04-20 12:32:32 +02:00
parent ef20a68d56
commit 0b7fd6ae2a
2 changed files with 22 additions and 0 deletions
+9
View File
@@ -0,0 +1,9 @@
import re
def match(command, settings):
return ('rm' in command.script
and 'is a directory' in command.stderr)
def get_new_command(command, settings):
return re.sub('^rm (.*)', 'rm -rf \\1', command.script)