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)