mirror of
https://github.com/nvbn/thefuck.git
synced 2025-04-14 06:40:49 +01: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
|
from . import read_log, rerun
|
||||||
|
|
||||||
|
|
||||||
def get_output(script):
|
def get_output(script, expanded):
|
||||||
if settings.instant_mode:
|
if settings.instant_mode:
|
||||||
return read_log.get_output(script)
|
return read_log.get_output(script, expanded)
|
||||||
else:
|
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
|
return screen.display
|
||||||
|
|
||||||
|
|
||||||
def get_output(script):
|
def get_output(script, _):
|
||||||
if 'THEFUCK_OUTPUT_LOG' not in os.environ:
|
if 'THEFUCK_OUTPUT_LOG' not in os.environ:
|
||||||
warn("Output log isn't specified")
|
warn("Output log isn't specified")
|
||||||
return None, None
|
return None, None
|
||||||
|
@ -28,14 +28,14 @@ def _wait_output(popen, is_slow):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def get_output(script):
|
def get_output(script, expanded):
|
||||||
env = dict(os.environ)
|
env = dict(os.environ)
|
||||||
env.update(settings.env)
|
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(
|
with logs.debug_time(u'Call: {}; with env: {}; is slow: '.format(
|
||||||
script, env, is_slow)):
|
script, env, is_slow)):
|
||||||
result = Popen(script, shell=True, stdin=PIPE,
|
result = Popen(expanded, shell=True, stdin=PIPE,
|
||||||
stdout=PIPE, stderr=PIPE, env=env)
|
stdout=PIPE, stderr=PIPE, env=env)
|
||||||
if _wait_output(result, is_slow):
|
if _wait_output(result, is_slow):
|
||||||
stdout = result.stdout.read().decode('utf-8')
|
stdout = result.stdout.read().decode('utf-8')
|
||||||
|
@ -72,8 +72,9 @@ class Command(object):
|
|||||||
if not script:
|
if not script:
|
||||||
raise EmptyCommand
|
raise EmptyCommand
|
||||||
|
|
||||||
stdout, stderr = get_output(script)
|
expanded = shell.from_shell(script)
|
||||||
return cls(script, stdout, stderr)
|
stdout, stderr = get_output(script, expanded)
|
||||||
|
return cls(expanded, stdout, stderr)
|
||||||
|
|
||||||
|
|
||||||
class Rule(object):
|
class Rule(object):
|
||||||
|
@ -291,12 +291,9 @@ def format_raw_script(raw_script):
|
|||||||
:rtype: basestring
|
:rtype: basestring
|
||||||
|
|
||||||
"""
|
"""
|
||||||
from .shells import shell
|
|
||||||
|
|
||||||
if six.PY2:
|
if six.PY2:
|
||||||
script = ' '.join(arg.decode('utf-8') for arg in raw_script)
|
script = ' '.join(arg.decode('utf-8') for arg in raw_script)
|
||||||
else:
|
else:
|
||||||
script = ' '.join(raw_script)
|
script = ' '.join(raw_script)
|
||||||
|
|
||||||
script = script.strip()
|
return script.strip()
|
||||||
return shell.from_shell(script)
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user