1
0
mirror of https://github.com/nvbn/thefuck.git synced 2024-10-05 18:31:10 +01:00

#682: Fix aliases in instant mode

This commit is contained in:
Vladimir Iakovlev 2017-08-26 06:29:38 +02:00
parent c4848d1816
commit 0ecc86eda6
5 changed files with 11 additions and 13 deletions

View File

@ -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)

View File

@ -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

View File

@ -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')

View File

@ -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):

View File

@ -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()