From 3407a2f7419e49be8b3fa94a0fa35b404f20f038 Mon Sep 17 00:00:00 2001 From: Yoav Tzelnick Date: Fri, 25 Oct 2019 00:51:47 +0300 Subject: [PATCH] Set rm / to be a safe call --- tests/rules/test_rm_root.py | 8 +++----- thefuck/rules/rm_root.py | 6 ++---- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/tests/rules/test_rm_root.py b/tests/rules/test_rm_root.py index 99cb0af9..b6ff9529 100644 --- a/tests/rules/test_rm_root.py +++ b/tests/rules/test_rm_root.py @@ -4,17 +4,15 @@ from thefuck.types import Command def test_match(): - assert match(Command('rm -rf /', 'add --no-preserve-root')) + assert match(Command('rm -rf /', '')) @pytest.mark.parametrize('command', [ Command('ls', 'add --no-preserve-root'), - Command('rm --no-preserve-root /', 'add --no-preserve-root'), - Command('rm -rf /', '')]) + Command('rm', '/usr/bin/python')]) def test_not_match(command): assert not match(command) def test_get_new_command(): - assert (get_new_command(Command('rm -rf /', '')) - == 'rm -rf / --no-preserve-root') + assert 'rm' not in (get_new_command(Command('rm -rf /', ''))) diff --git a/thefuck/rules/rm_root.py b/thefuck/rules/rm_root.py index 3eb3047d..8f4ccbae 100644 --- a/thefuck/rules/rm_root.py +++ b/thefuck/rules/rm_root.py @@ -6,11 +6,9 @@ enabled_by_default = False @sudo_support def match(command): return (command.script_parts - and {'rm', '/'}.issubset(command.script_parts) - and '--no-preserve-root' not in command.script - and '--no-preserve-root' in command.output) + and {'rm', '/'}.issubset(command.script_parts)) @sudo_support def get_new_command(command): - return u'{} --no-preserve-root'.format(command.script) + return u'echo "I\'m saving your life. Thank me later"'