From 2ca0e4d968cf4f374c845e54b4c9e01916c4e280 Mon Sep 17 00:00:00 2001 From: braham delam Date: Tue, 26 Nov 2019 21:36:14 -0500 Subject: [PATCH] fix missing_space_before_subcommand.py to ensure that apt-get commands weren't automatically converted into apt -get commands --- .../rules/missing_space_before_subcommand.py | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/thefuck/rules/missing_space_before_subcommand.py b/thefuck/rules/missing_space_before_subcommand.py index 410cb4bc..da71bfd6 100644 --- a/thefuck/rules/missing_space_before_subcommand.py +++ b/thefuck/rules/missing_space_before_subcommand.py @@ -1,3 +1,4 @@ + from thefuck.utils import get_all_executables, memoize @@ -5,7 +6,23 @@ from thefuck.utils import get_all_executables, memoize def _get_executable(script_part): for executable in get_all_executables(): if script_part.startswith(executable): - return executable + if executable.startswith("apt"): + if script_part.startswith("apt-get"): + return "apt-get" + count = 0 + if "g" in script_part: + count += 1 + if "e" in script_part: + count += 1 + if script_part.find("t", 3, -1) != -1: + count += 1 + if "-" in script_part: + count += 1 + if count < 3 or len(script_part) > count + 4: + return executable + + else: + return executable def match(command): @@ -19,3 +36,4 @@ def get_new_command(command): priority = 4000 +