mirror of
https://github.com/nvbn/thefuck.git
synced 2025-04-09 20:30:47 +01:00
20 lines
528 B
Python
20 lines
528 B
Python
import six
|
|
from decorator import decorator
|
|
from ..types import Command
|
|
|
|
|
|
@decorator
|
|
def sudo_support(fn, command):
|
|
"""Removes sudo before calling fn and adds it after."""
|
|
if not command.script.startswith('sudo '):
|
|
return fn(command)
|
|
|
|
result = fn(command.update(script=command.script[5:]))
|
|
|
|
if result and isinstance(result, six.string_types):
|
|
return u'sudo {}'.format(result)
|
|
elif isinstance(result, list):
|
|
return [u'sudo {}'.format(x) for x in result]
|
|
else:
|
|
return result
|