diff --git a/thefuck/entrypoints/main.py b/thefuck/entrypoints/main.py index 01346870..865b9ca1 100644 --- a/thefuck/entrypoints/main.py +++ b/thefuck/entrypoints/main.py @@ -22,10 +22,13 @@ def main(): elif known_args.version: logs.version(get_installation_info().version, sys.version.split()[0], shell.info()) - elif known_args.command or 'TF_HISTORY' in os.environ: - fix_command(known_args) + # It's important to check if an alias is being requested before checking if + # `TF_HISTORY` is in `os.environ`, otherwise it might mess with subshells. + # Check https://github.com/nvbn/thefuck/issues/921 for reference elif known_args.alias: print_alias(known_args) + elif known_args.command or 'TF_HISTORY' in os.environ: + fix_command(known_args) elif known_args.shell_logger: try: from .shell_logger import shell_logger # noqa: E402