From b0d353c699df50c0a40d21d1d0a708046af6bb9c Mon Sep 17 00:00:00 2001 From: nvbn Date: Sat, 18 Apr 2015 21:30:48 +0200 Subject: [PATCH] #22 Simplify adding patterns for the `sudo` rule --- setup.py | 2 +- thefuck/rules/sudo.py | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index c7775b95..ccc60cf4 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup, find_packages setup(name='thefuck', - version=1.8, + version=1.9, description="Magnificent app which corrects your previous console command", author='Vladimir Iakovlev', author_email='nvbn.rm@gmail.com', diff --git a/thefuck/rules/sudo.py b/thefuck/rules/sudo.py index 4fa10123..36ec9631 100644 --- a/thefuck/rules/sudo.py +++ b/thefuck/rules/sudo.py @@ -1,7 +1,14 @@ +patterns = ['permission denied', + 'EACCES', + 'pkg: Insufficient privileges', + 'you cannot perform this operation unless you are root'] + + def match(command, settings): - return ('permission denied' in command.stderr.lower() - or 'EACCES' in command.stderr - or 'pkg: Insufficient privileges' in command.stderr) + for pattern in patterns: + if pattern.lower() in command.stderr.lower(): + return True + return False def get_new_command(command, settings):