File tree Expand file tree Collapse file tree 1 file changed +21
-8
lines changed
Expand file tree Collapse file tree 1 file changed +21
-8
lines changed Original file line number Diff line number Diff line change @@ -91,13 +91,13 @@ exit /b
9191
9292 if /i " !position! " == " append" (
9393 if " !found! " == " 0" (
94- echo " !PATH! " | !WINDIR! \System32\findstr > nul /I /R /C:" ;!find_query! \ " $"
94+ echo " !PATH! " | !WINDIR! \System32\findstr > nul /I /R /C:" ;!find_query! $"
9595 call :set_found
9696 )
9797 %print_debug% :enhance_path " Env Var END PATH !find_query! - found=!found! "
9898 ) else (
9999 if " !found! " == " 0" (
100- echo " !PATH! " | !WINDIR! \System32\findstr > nul /I /R /C:" ^\ " !find_query! ;"
100+ echo " !PATH! " | !WINDIR! \System32\findstr > nul /I /R /C:" ^!find_query! ;"
101101 call :set_found
102102 )
103103 %print_debug% :enhance_path " Env Var BEGIN PATH !find_query! - found=!found! "
@@ -190,13 +190,28 @@ exit /b
190190 exit /b 1
191191 )
192192
193+ rem Parse arguments robustly:
194+ rem Accept either public form: "[dir_path]" [max_depth] [append]
195+ rem or internal recursive form: "[dir_path]" [depth] [max_depth] [append]
193196 set " depth = %~2 "
194197 set " max_depth = %~3 "
198+ set " position = "
195199
196- if " %~4 " neq " " if /i " %~4 " == " append" (
197- set " position = %~4 "
198- ) else (
199- set " position = "
200+ if /i " %~4 " == " append" set " position = append"
201+ if /i " %~3 " == " append" (
202+ set " position = append"
203+ set " max_depth = "
204+ )
205+
206+ if not defined depth set " depth = 0"
207+ if not defined max_depth (
208+ if defined depth (
209+ rem If only one numeric argument provided, treat it as max_depth
210+ set " max_depth = %depth% "
211+ set " depth = 0"
212+ ) else (
213+ set " max_depth = 1"
214+ )
200215 )
201216
202217 dir " %add_path% " 2 > NUL | findstr -i -e " %find_pathext% " > NUL
@@ -232,8 +247,6 @@ exit /b
232247 call :loop_depth
233248 )
234249
235- set " PATH = %PATH% "
236-
237250 exit /b
238251
239252:set_depth
You can’t perform that action at this time.
0 commit comments