Added systemctl rule

This commit is contained in:
Maciej Mionskowski
2015-06-24 09:36:09 +02:00
parent c6aead735b
commit 360e4673eb
2 changed files with 34 additions and 0 deletions
+16
View File
@@ -0,0 +1,16 @@
"""
The confusion in systemctl's param order is massive
"""
from thefuck.utils import sudo_support
@sudo_support
def match(command, settings):
#Catches 'Unknown operation 'service'.' when executing systemctl with misordered arguments
cmd = command.script.split()
return ('systemctl' in command.script) and ('Unknown operation \'' in command.stderr) and (len(cmd) - cmd.index('systemctl') == 3);
@sudo_support
def get_new_command(command, settings):
cmd = command.script.split()
cmd[len(cmd)-1], cmd[len(cmd)-2] = cmd[len(cmd)-2], cmd[len(cmd)-1]
return ' '.join(cmd)