From f59aa931c3d76b40b2078cf2926b239dc0798b74 Mon Sep 17 00:00:00 2001 From: Alex Barcelo Date: Fri, 16 Feb 2018 23:43:43 +0100 Subject: [PATCH] rewritten match + fish output check for cd_* rules --- tests/rules/test_cd_correction.py | 2 +- thefuck/rules/cd_correction.py | 9 ++++++--- thefuck/rules/cd_mkdir.py | 9 +++++---- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/tests/rules/test_cd_correction.py b/tests/rules/test_cd_correction.py index f790b2d..d257658 100644 --- a/tests/rules/test_cd_correction.py +++ b/tests/rules/test_cd_correction.py @@ -1,5 +1,5 @@ import pytest -from thefuck.rules.cd_correction import match, get_new_command +from thefuck.rules.cd_correction import match from thefuck.types import Command diff --git a/thefuck/rules/cd_correction.py b/thefuck/rules/cd_correction.py index 5dded56..376e51e 100644 --- a/thefuck/rules/cd_correction.py +++ b/thefuck/rules/cd_correction.py @@ -21,9 +21,12 @@ def _get_sub_dirs(parent): @for_app('cd') def match(command): """Match function copied from cd_mkdir.py""" - return (command.script.startswith('cd ') - and ('no such file or directory' in command.output.lower() - or 'cd: can\'t cd to' in command.output.lower())) + return ( + command.script.startswith('cd ') and any(( + 'no such file or directory' in command.output.lower(), + 'cd: can\'t cd to' in command.output.lower(), + 'does not exist' in command.output.lower() + ))) @sudo_support diff --git a/thefuck/rules/cd_mkdir.py b/thefuck/rules/cd_mkdir.py index 09e3ab6..363b92d 100644 --- a/thefuck/rules/cd_mkdir.py +++ b/thefuck/rules/cd_mkdir.py @@ -8,10 +8,11 @@ from thefuck.shells import shell @for_app('cd') def match(command): return ( - 'no such file or directory' in command.output.lower() - or 'cd: can\'t cd to' in command.output.lower() - or 'the system cannot find the path specified.' in command.output.lower() - ) + command.script.startswith('cd ') and any(( + 'no such file or directory' in command.output.lower(), + 'cd: can\'t cd to' in command.output.lower(), + 'does not exist' in command.output.lower() + ))) @sudo_support