mirror of
https://github.com/nvbn/thefuck.git
synced 2025-02-21 20:38:54 +00:00
#415: Prevent double sudo
This commit is contained in:
parent
b65a9a0a4f
commit
c3b1ba7637
@ -19,6 +19,7 @@ def test_match(stderr, stdout):
|
|||||||
|
|
||||||
def test_not_match():
|
def test_not_match():
|
||||||
assert not match(Command())
|
assert not match(Command())
|
||||||
|
assert not match(Command(script='sudo ls', stderr='Permission denied'))
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('before, after', [
|
@pytest.mark.parametrize('before, after', [
|
||||||
|
@ -21,6 +21,9 @@ patterns = ['permission denied',
|
|||||||
|
|
||||||
|
|
||||||
def match(command):
|
def match(command):
|
||||||
|
if command.script_parts and command.script_parts[0] == 'sudo':
|
||||||
|
return False
|
||||||
|
|
||||||
for pattern in patterns:
|
for pattern in patterns:
|
||||||
if pattern.lower() in command.stderr.lower()\
|
if pattern.lower() in command.stderr.lower()\
|
||||||
or pattern.lower() in command.stdout.lower():
|
or pattern.lower() in command.stdout.lower():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user