mirror of
https://github.com/nvbn/thefuck.git
synced 2025-02-20 20:09:07 +00:00
#326 Add support of sudo with pipes
This commit is contained in:
parent
41a0a766ce
commit
b29113c229
@ -21,5 +21,9 @@ def test_not_match():
|
||||
assert not match(Command(), None)
|
||||
|
||||
|
||||
def test_get_new_command():
|
||||
assert get_new_command(Command('ls'), None) == 'sudo ls'
|
||||
@pytest.mark.parametrize('before, after', [
|
||||
('ls', 'sudo ls'),
|
||||
('echo a > b', 'sudo sh -c "echo a > b"'),
|
||||
('echo "a" >> b', 'sudo sh -c "echo \\"a\\" >> b"')])
|
||||
def test_get_new_command(before, after):
|
||||
assert get_new_command(Command(before), None) == after
|
||||
|
@ -28,4 +28,7 @@ def match(command, settings):
|
||||
|
||||
|
||||
def get_new_command(command, settings):
|
||||
return u'sudo {}'.format(command.script)
|
||||
if '>' in command.script:
|
||||
return u'sudo sh -c "{}"'.format(command.script.replace('"', '\\"'))
|
||||
else:
|
||||
return u'sudo {}'.format(command.script)
|
||||
|
Loading…
x
Reference in New Issue
Block a user