From 7ceacb63ddaa08f41fc92020a99f659f561df3e3 Mon Sep 17 00:00:00 2001 From: David Refoua Date: Thu, 14 Nov 2024 00:00:53 +0330 Subject: [PATCH] respect PATHEXT instead of hardcoding our own value * support other path extensions as well (e.g. `.py` commonly used) --- vendor/lib/lib_path.cmd | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/vendor/lib/lib_path.cmd b/vendor/lib/lib_path.cmd index 36f4fb1..e91efab 100644 --- a/vendor/lib/lib_path.cmd +++ b/vendor/lib/lib_path.cmd @@ -10,6 +10,13 @@ if "%~1" == "/h" ( call :%* ) +setlocal enabledelayedexpansion +if not defined find_pathext ( + set "find_pathext=!PATHEXT:;= !" + set "find_pathext=!find_pathext:.=\.!" +) +endlocal & set "find_pathext=%find_pathext%" + exit /b :enhance_path @@ -50,7 +57,7 @@ exit /b set "position=" ) - dir "%add_path%" 2>NUL | findstr -i "\.COM \.EXE \.BAT \.CMD \.PS1 \.VBS" >NUL + dir "%add_path%" 2>NUL | findstr -i -e "%find_pathext%" >NUL if "%ERRORLEVEL%" == "0" ( set "add_to_path=%add_path%" @@ -184,7 +191,7 @@ exit /b set "position=" ) - dir "%add_path%" 2>NUL | findstr -i "\.COM \.EXE \.BAT \.CMD \.PS1 \.VBS" >NUL + dir "%add_path%" 2>NUL | findstr -i -e "%find_pathext%" >NUL if "%ERRORLEVEL%" == "0" ( set "add_to_path=%add_path%"