1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-11-18 07:46:11 +00:00
Files
thefuck/thefuck/rules/sudo.py
mcarton 12f8d017b9 Add systemd's kind of error for the sudo rule
A complete error would be:

```
% systemctl daemon-reload
==== AUTHENTICATING FOR org.freedesktop.systemd1.reload-daemon ===
Authentication is required to reload the systemd state.
Authenticating as: martin
Password:
```
2015-07-09 17:24:45 +02:00

30 lines
982 B
Python

patterns = ['permission denied',
'EACCES',
'pkg: Insufficient privileges',
'you cannot perform this operation unless you are root',
'non-root users cannot',
'Operation not permitted',
'root privilege',
'This command has to be run under the root user.',
'This operation requires root.',
'requested operation requires superuser privilege',
'must be run as root',
'must be superuser',
'must be root',
'need to be root',
'need root',
'only root can do that',
'authentication is required']
def match(command, settings):
for pattern in patterns:
if pattern.lower() in command.stderr.lower()\
or pattern.lower() in command.stdout.lower():
return True
return False
def get_new_command(command, settings):
return u'sudo {}'.format(command.script)