mirror of
https://github.com/nvbn/thefuck.git
synced 2025-04-19 01:00:42 +01:00
Fallback to su if sudo doesn't exist
This commit is contained in:
parent
70b414aca2
commit
cdb1965c9b
15
thefuck/rules/su.py
Normal file
15
thefuck/rules/su.py
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
def match(command):
|
||||||
|
if command.script_parts and '&&' not in command.script_parts and command.script_parts[0] == 'su':
|
||||||
|
return False
|
||||||
|
|
||||||
|
return 'command not found: sudo' in command.output.lower()
|
||||||
|
|
||||||
|
|
||||||
|
def get_new_command(command):
|
||||||
|
if '&&' in command.script:
|
||||||
|
return u'su -c "sh -c "{}""'.format(" ".join([part for part in command.script_parts if part != "sudo"]))
|
||||||
|
elif '>' in command.script:
|
||||||
|
return u'su -c "sh -c "{}""'.format(command.script.replace('"', '\\"'))
|
||||||
|
else:
|
||||||
|
return u'su -c {}'.format(command.script)
|
||||||
|
priority = 1200
|
Loading…
x
Reference in New Issue
Block a user