mirror of
https://github.com/nvbn/thefuck.git
synced 2025-02-22 12:58:33 +00:00
#682: Fix aliases in instant mode
This commit is contained in:
parent
c4848d1816
commit
0ecc86eda6
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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')
|
||||
|
@ -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):
|
||||
|
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user