From 69a1641a3cebe885c349b934652a3f01dac6f1e0 Mon Sep 17 00:00:00 2001 From: Yoav Tzelnick Date: Fri, 1 Nov 2019 02:38:32 +0200 Subject: [PATCH] Added side_effect to support destroying system --- thefuck/rules/rm_root.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/thefuck/rules/rm_root.py b/thefuck/rules/rm_root.py index 8f4ccbae..c064d62d 100644 --- a/thefuck/rules/rm_root.py +++ b/thefuck/rules/rm_root.py @@ -1,3 +1,5 @@ +import sys +from warnings import warn from thefuck.specific.sudo import sudo_support enabled_by_default = False @@ -9,6 +11,16 @@ def match(command): and {'rm', '/'}.issubset(command.script_parts)) -@sudo_support def get_new_command(command): - return u'echo "I\'m saving your life. Thank me later"' + return '{} {} {}'.format(command.script_parts[0], '-rf', ' '.join(command.script_parts[1:])) + + +def side_effect(old_cmd, command): + warn("DANGER!!! THIS MAY DESTROY YOUR SYSTEM! ARE YOU SURE? (y/N): ") + try: + input = raw_input + except NameError: + pass + reply = input().strip().lower() # raw_input should be used in Python 2 + if not reply or reply[0] != "y": + sys.exit(0)