upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/tools/mc_command.py
diff options
context:
space:
mode:
authorlordon1a <183556939+lordon1a@users.noreply.github.com>2026-11-24 02:08:49 +0300
committerClaude <noreply@anthropic.com>2026-11-24 16:57:51 +0100
commitc580e0347db3694bbbe9a285b025073e69eeeaa1 (patch)
tree62536b80674be37eb1793c4b4cb8e7a682c9c0f2 /tools/mc_command.py
parent1504c1af63aeab49fb451ee42d3d051b29d4c976 (diff)
tools/mc_command: check PATHEXT on Windows when shutil.which misses path without extension
Diffstat (limited to 'tools/mc_command.py')
-rw-r--r--tools/mc_command.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/tools/mc_command.py b/tools/mc_command.py
index 762008d7a..2f90d9172 100644
--- a/tools/mc_command.py
+++ b/tools/mc_command.py
@@ -71,10 +71,16 @@ def split_command(raw: str) -> list[str]:
71 return [] 71 return []
72 if os.path.isfile(raw): 72 if os.path.isfile(raw):
73 return [raw] # a plain path, spaces and all 73 return [raw] # a plain path, spaces and all
74 if ("/" in raw or "\\" in raw) and shutil.which(raw): 74 if "/" in raw or "\\" in raw:
75 # A path whose extension is left out (C:\Program Files\LLVM\bin\llvm-mc): Windows finds llvm-mc.exe 75 # A path whose extension is left out (C:\Program Files\LLVM\bin\llvm-mc): Windows finds llvm-mc.exe
76 # for it, but it is no file under that exact name, so it used to be split at its spaces. 76 # for it, but it is no file under that exact name, so it used to be split at its spaces.
77 return [raw] 77 # On Python 3.11 Windows, shutil.which() does not append PATHEXT when a directory component is present.
78 if shutil.which(raw):
79 return [raw]
80 if os.name == "nt":
81 for ext in os.environ.get("PATHEXT", ".COM;.EXE;.BAT;.CMD").split(os.pathsep):
82 if ext and os.path.isfile(raw + ext):
83 return [raw]
78 try: 84 try:
79 return split_windows_command(raw) if os.name == "nt" else shlex.split(raw) 85 return split_windows_command(raw) if os.name == "nt" else shlex.split(raw)
80 except ValueError as e: 86 except ValueError as e: