From 079fac3fe5c9d86b65be8582812b9b46855e5d3c Mon Sep 17 00:00:00 2001 From: paintedblue Date: Wed, 8 Nov 2023 17:27:08 +0900 Subject: [PATCH] Fix path strip issue in which function --- thefuck/utils.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/thefuck/utils.py b/thefuck/utils.py index 466e4ba51..6917ad26d 100644 --- a/thefuck/utils.py +++ b/thefuck/utils.py @@ -50,7 +50,6 @@ def which(program): """Returns `program` path or `None`.""" try: from shutil import which - return which(program) except ImportError: def is_exe(fpath): @@ -62,14 +61,18 @@ def is_exe(fpath): return program else: for path in os.environ["PATH"].split(os.pathsep): - path = path.strip('"') + # Strip only the whitespace by default + path = path.strip() + # Remove only the surrounding double quotes, if any + if path.startswith('"') and path.endswith('"'): + path = path[1:-1] exe_file = os.path.join(path, program) if is_exe(exe_file): return exe_file - return None + def default_settings(params): """Adds default values to settings if it not presented.