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:
parent
70b414aca2
commit
3407a2f741
@ -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 /', '')))
|
||||
|
@ -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"'
|
||||
|
Loading…
x
Reference in New Issue
Block a user