diff --git a/thefuck/output/__init__.py b/thefuck/output/__init__.py index 66e40866..cdd69d00 100644 --- a/thefuck/output/__init__.py +++ b/thefuck/output/__init__.py @@ -2,8 +2,8 @@ from ..conf import settings from . import read_log, rerun -def get_output(script): +def get_output(script, expanded): if settings.instant_mode: - return read_log.get_output(script) + return read_log.get_output(script, expanded) else: - return rerun.get_output(script) + return rerun.get_output(script, expanded) diff --git a/thefuck/output/read_log.py b/thefuck/output/read_log.py index 07a480eb..47dfa94d 100644 --- a/thefuck/output/read_log.py +++ b/thefuck/output/read_log.py @@ -53,7 +53,7 @@ def _get_output_lines(script, log_file): return screen.display -def get_output(script): +def get_output(script, _): if 'THEFUCK_OUTPUT_LOG' not in os.environ: warn("Output log isn't specified") return None, None diff --git a/thefuck/output/rerun.py b/thefuck/output/rerun.py index 2648384d..2583de98 100644 --- a/thefuck/output/rerun.py +++ b/thefuck/output/rerun.py @@ -28,14 +28,14 @@ def _wait_output(popen, is_slow): return False -def get_output(script): +def get_output(script, expanded): env = dict(os.environ) env.update(settings.env) - is_slow = shlex.split(script) in settings.slow_commands + is_slow = shlex.split(expanded) in settings.slow_commands with logs.debug_time(u'Call: {}; with env: {}; is slow: '.format( script, env, is_slow)): - result = Popen(script, shell=True, stdin=PIPE, + result = Popen(expanded, shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE, env=env) if _wait_output(result, is_slow): stdout = result.stdout.read().decode('utf-8') diff --git a/thefuck/types.py b/thefuck/types.py index 872daa9b..b5e84833 100644 --- a/thefuck/types.py +++ b/thefuck/types.py @@ -72,8 +72,9 @@ class Command(object): if not script: raise EmptyCommand - stdout, stderr = get_output(script) - return cls(script, stdout, stderr) + expanded = shell.from_shell(script) + stdout, stderr = get_output(script, expanded) + return cls(expanded, stdout, stderr) class Rule(object): diff --git a/thefuck/utils.py b/thefuck/utils.py index c1746004..1de4b63a 100644 --- a/thefuck/utils.py +++ b/thefuck/utils.py @@ -291,12 +291,9 @@ def format_raw_script(raw_script): :rtype: basestring """ - from .shells import shell - if six.PY2: script = ' '.join(arg.decode('utf-8') for arg in raw_script) else: script = ' '.join(raw_script) - script = script.strip() - return shell.from_shell(script) + return script.strip()