Skip to content

Commit

Permalink
respect PATHEXT instead of hardcoding our own value
Browse files Browse the repository at this point in the history
* support other path extensions as well (e.g. `.py` commonly used)
  • Loading branch information
DRSDavidSoft committed Nov 13, 2024
1 parent 5101788 commit 7ceacb6
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions vendor/lib/lib_path.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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%"
Expand Down Expand Up @@ -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%"
Expand Down

0 comments on commit 7ceacb6

Please sign in to comment.