diff --git a/thefuck/rules/missing_space_before_subcommand.py b/thefuck/rules/missing_space_before_subcommand.py index 2f86fe18..41711c6c 100644 --- a/thefuck/rules/missing_space_before_subcommand.py +++ b/thefuck/rules/missing_space_before_subcommand.py @@ -1,27 +1,32 @@ + from thefuck.utils import get_all_executables, memoize @memoize -def _get_executable(script_part): +def _get_executables(script_part): + executable_list = [] for executable in get_all_executables(): if script_part.startswith(executable): - if executable.startswith("apt"): - if script_part.startswith("apt-get"): - if len(script_part) > len("apt-get"): - return "apt-get" - else: - return - return executable + executable_list.append(executable) + return executable_list def match(command): return (not command.script_parts[0] in get_all_executables() - and _get_executable(command.script_parts[0])) + and len(_get_executables(command.script_parts[0])) != 0) def get_new_command(command): - executable = _get_executable(command.script_parts[0]) - return command.script.replace(executable, u'{} '.format(executable), 1) + executables = _get_executables(command.script_parts[0]) + new_command_scripts = [] + # return all possible command lines + for each_exec in executables: + temp_line = command.script + new_command_scripts.append(temp_line.replace( + each_exec, u'{} '.format(each_exec), 1)) + + return new_command_scripts priority = 4000 +