11@ echo off
22
3-
43call " %~dp0 lib_base.cmd"
54call " %% ~dp0lib_console"
65set lib_path = call " %~dp0 lib_path.cmd"
@@ -11,6 +10,13 @@ if "%~1" == "/h" (
1110 call :%*
1211)
1312
13+ setlocal enabledelayedexpansion
14+ if not defined find_pathext (
15+ set " find_pathext = !PATHEXT:; = ! "
16+ set " find_pathext = !find_pathext:. =\. ! "
17+ )
18+ endlocal & set " find_pathext = %find_pathext% "
19+
1420exit /b
1521
1622:enhance_path
@@ -32,13 +38,12 @@ exit /b
3238:: :options:
3339:: :
3440:: : append <in> Append to the path env variable rather than pre-pend.
35- :: B
41+ :: :
3642:: :
3743:: :output:
3844:: :
3945:: : path <out> Sets the path env variable if required.
4046:: :-------------------------------------------------------------------------------
41-
4247 if " %~1 " neq " " (
4348 set " add_path = %~1 "
4449 ) else (
@@ -52,7 +57,8 @@ exit /b
5257 set " position = "
5358 )
5459
55- dir " %add_path% " | findstr -i " \.COM \.EXE \.BAT \.CMD \.PS1 \.VBS" > NUL
60+ dir " %add_path% " 2 > NUL | findstr -i -e " %find_pathext% " > NUL
61+
5662 if " %ERRORLEVEL% " == " 0" (
5763 set " add_to_path = %add_path% "
5864 ) else (
@@ -81,20 +87,20 @@ exit /b
8187 echo " !path! " | !WINDIR! \System32\findstr > nul /I /R /C:" ;!find_query! ;"
8288 call :set_found
8389 )
84- %print_debug% :enhance_path " Env Var INSIDE PATH !find_query! - found=!found! "
90+ %print_debug% :enhance_path " Env Var INSIDE PATH !find_query! - found=!found! "
8591
8692 if /i " !position! " == " append" (
8793 if " !found! " == " 0" (
8894 echo " !path! " | !WINDIR! \System32\findstr > nul /I /R /C:" ;!find_query! \" $"
8995 call :set_found
9096 )
91- %print_debug% :enhance_path " Env Var END PATH !find_query! - found=!found! "
97+ %print_debug% :enhance_path " Env Var END PATH !find_query! - found=!found! "
9298 ) else (
9399 if " !found! " == " 0" (
94100 echo " !path! " | !WINDIR! \System32\findstr > nul /I /R /C:" ^\" !find_query! ;"
95101 call :set_found
96102 )
97- %print_debug% :enhance_path " Env Var BEGIN PATH !find_query! - found=!found! "
103+ %print_debug% :enhance_path " Env Var BEGIN PATH !find_query! - found=!found! "
98104 )
99105 endlocal & set found = %found%
100106
@@ -129,13 +135,12 @@ exit /b
129135 exit /b
130136
131137 :changed
132- %print_debug% :enhance_path " END Env Var - PATH=%path% "
133- %print_debug% :enhance_path " Env Var %find_query% - found=%found% "
138+ %print_debug% :enhance_path " END Env Var - PATH=%path% "
139+ %print_debug% :enhance_path " Env Var %find_query% - found=%found% "
134140 exit /b
135141
136142 exit /b
137143
138-
139144:set_found
140145 if " %ERRORLEVEL% " == " 0" (
141146 set found = 1
@@ -190,7 +195,7 @@ exit /b
190195 set " position = "
191196 )
192197
193- dir " %add_path% " 2 > NUL | findstr -i " \.COM \.EXE \.BAT \.CMD \.PS1 \.VBS " > NUL
198+ dir " %add_path% " 2 > NUL | findstr -i -e " %find_pathext% " > NUL
194199
195200 if " %ERRORLEVEL% " == " 0" (
196201 set " add_to_path = %add_path% "
@@ -204,7 +209,7 @@ exit /b
204209 set " path = %path% ;%add_to_path% "
205210 ) else (
206211 set " path = %add_to_path% ;%path% "
207- )
212+ )
208213 )
209214 )
210215
@@ -213,10 +218,10 @@ exit /b
213218 exit /b
214219 )
215220
216- %print_debug% :set_path_recursive " Env Var - add_path=%add_to_path% "
217- %print_debug% :set_path_recursive " Env Var - position=%position% "
218- %print_debug% :set_path_recursive " Env Var - depth=%depth% "
219- %print_debug% :set_path_recursive " Env Var - max_depth=%max_depth% "
221+ %print_debug% :set_path_recursive " Env Var - add_path=%add_to_path% "
222+ %print_debug% :set_path_recursive " Env Var - position=%position% "
223+ %print_debug% :set_path_recursive " Env Var - depth=%depth% "
224+ %print_debug% :set_path_recursive " Env Var - max_depth=%max_depth% "
220225
221226 if %max_depth% gtr %depth% (
222227 if " %add_to_path% " neq " " (
@@ -225,7 +230,7 @@ exit /b
225230 set " path = %path% ;%add_to_path% "
226231 ) else (
227232 set " path = %add_to_path% ;%path% "
228- )
233+ )
229234 )
230235 call :set_depth
231236 call :loop_depth
@@ -235,7 +240,7 @@ exit /b
235240
236241 exit /b
237242
238- : set_depth
243+ :set_depth
239244 set /a " depth = %depth% + 1"
240245 exit /b
241246
@@ -245,10 +250,16 @@ exit /b
245250 )
246251
247252 for /d %%i in (" %add_path% \*" ) do (
253+ <<<<<<< HEAD
248254 %print_debug% :set_path_recursive " Env Var BEFORE - depth=%depth% "
249255 %print_debug% :set_path_recursive " Found Subdirectory - '%%~fi '"
250256 call :set_path_recursive " %%~fi " %depth% %max_depth% %position%
251257 %print_debug% :set_path_recursive " Env Var AFTER- depth=%depth% "
258+ ====== =
259+ %print_debug% :enhance_path_recursive " Env Var BEFORE - depth=%depth% "
260+ %print_debug% :enhance_path_recursive " Found Subdirectory - '%%~fi '"
261+ call :enhance_path_recursive " %%~fi " %depth% %max_depth% %position%
262+ %print_debug% :enhance_path_recursive " Env Var AFTER- depth=%depth% "
263+ >>>>>>> 126347025f9cade241beff182738b2527da7535e
252264 )
253265 exit /b
254-
0 commit comments