From 2a79a5e413b41bbbe3886828a97958ca824e7bdc Mon Sep 17 00:00:00 2001 From: SpyCheese Date: Sun, 19 Apr 2015 09:03:34 +0500 Subject: [PATCH 1/3] Create rm_root.py --- thefuck/rules/rm_root.py | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 thefuck/rules/rm_root.py diff --git a/thefuck/rules/rm_root.py b/thefuck/rules/rm_root.py new file mode 100644 index 00000000..95d9fbdd --- /dev/null +++ b/thefuck/rules/rm_root.py @@ -0,0 +1,8 @@ +def match(command, settings): + return ('rm' in command.script + and '--help' not in command.script + and '--no-preserve-root' in command.stderr) + + +def get_new_command(command, settings): + return '{} --no-preserve-root'.format(command.script) From f113bae59d97ab1cd90857680e8c6e9320b96327 Mon Sep 17 00:00:00 2001 From: SpyCheese Date: Sun, 19 Apr 2015 09:12:19 +0500 Subject: [PATCH 2/3] Update rm_root.py --- thefuck/rules/rm_root.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/thefuck/rules/rm_root.py b/thefuck/rules/rm_root.py index 95d9fbdd..b97eda22 100644 --- a/thefuck/rules/rm_root.py +++ b/thefuck/rules/rm_root.py @@ -1,6 +1,6 @@ def match(command, settings): - return ('rm' in command.script - and '--help' not in command.script + return ('/' in command.script + and '--no-preserve-root' not in command.script and '--no-preserve-root' in command.stderr) From ceeccf1cd7de156ae48ce5aa7f01366015fa6de9 Mon Sep 17 00:00:00 2001 From: SpyCheese Date: Sun, 19 Apr 2015 10:21:46 +0500 Subject: [PATCH 3/3] Update rm_root.py Okay, there was an incorrect match function. --- thefuck/rules/rm_root.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/thefuck/rules/rm_root.py b/thefuck/rules/rm_root.py index b97eda22..853ce847 100644 --- a/thefuck/rules/rm_root.py +++ b/thefuck/rules/rm_root.py @@ -1,5 +1,5 @@ def match(command, settings): - return ('/' in command.script + return ('/' in command.script.split() and '--no-preserve-root' not in command.script and '--no-preserve-root' in command.stderr)