1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-02-07 13:41:21 +00:00

Set rm / to be a safe call

This commit is contained in:
Yoav Tzelnick 2019-10-25 00:51:47 +03:00
parent 70b414aca2
commit 3407a2f741
No known key found for this signature in database
GPG Key ID: 03A2C2EC8B8E9782
2 changed files with 5 additions and 9 deletions

View File

@ -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 /', '')))

View File

@ -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"'