mirror of
https://github.com/nvbn/thefuck.git
synced 2025-02-12 07:59:01 +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():
|
def test_match():
|
||||||
assert match(Command('rm -rf /', 'add --no-preserve-root'))
|
assert match(Command('rm -rf /', ''))
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('command', [
|
@pytest.mark.parametrize('command', [
|
||||||
Command('ls', 'add --no-preserve-root'),
|
Command('ls', 'add --no-preserve-root'),
|
||||||
Command('rm --no-preserve-root /', 'add --no-preserve-root'),
|
Command('rm', '/usr/bin/python')])
|
||||||
Command('rm -rf /', '')])
|
|
||||||
def test_not_match(command):
|
def test_not_match(command):
|
||||||
assert not match(command)
|
assert not match(command)
|
||||||
|
|
||||||
|
|
||||||
def test_get_new_command():
|
def test_get_new_command():
|
||||||
assert (get_new_command(Command('rm -rf /', ''))
|
assert 'rm' not in (get_new_command(Command('rm -rf /', '')))
|
||||||
== 'rm -rf / --no-preserve-root')
|
|
||||||
|
@ -6,11 +6,9 @@ enabled_by_default = False
|
|||||||
@sudo_support
|
@sudo_support
|
||||||
def match(command):
|
def match(command):
|
||||||
return (command.script_parts
|
return (command.script_parts
|
||||||
and {'rm', '/'}.issubset(command.script_parts)
|
and {'rm', '/'}.issubset(command.script_parts))
|
||||||
and '--no-preserve-root' not in command.script
|
|
||||||
and '--no-preserve-root' in command.output)
|
|
||||||
|
|
||||||
|
|
||||||
@sudo_support
|
@sudo_support
|
||||||
def get_new_command(command):
|
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