This commit is contained in:
Dax T. Games
2019-10-13 15:47:25 -04:00
parent db42252ef2
commit 468dba474e
3 changed files with 134 additions and 87 deletions

View File

@ -64,7 +64,7 @@ exit /b
exit /b
)
setlocal enabledelayedexpansion
rem setlocal enabledelayedexpansion
set found=0
set "find_query=%add_path%"
@ -74,20 +74,22 @@ exit /b
if "%CMDER_CONFIGURED%" == "1" (
%lib_console% debug_output :enhance_path "Env Var - find_query=%find_query%"
echo "%path%"|%WINDIR%\System32\findstr >nul /I /R ";%find_query%\"$"
if "!ERRORLEVEL!" == "0" set found=1
REM if "!ERRORLEVEL!" == "0" set found=1
call :set_found
)
%lib_console% debug_output :enhance_path "Env Var 1 - found=!found!"
%lib_console% debug_output :enhance_path "Env Var 1 - found=%found%"
if "!found!" == "0" (
if "%found%" == "0" (
if "%CMDER_CONFIGURED%" == "1" (
echo "%path%"|%WINDIR%\System32\findstr >nul /i /r ";%find_query%;"
if "!ERRORLEVEL!" == "0" set found=1
REM if "!ERRORLEVEL!" == "0" set found=1
call :set_found
)
%lib_console% debug_output :enhance_path "Env Var 2 - found=!found!"
%lib_console% debug_output :enhance_path "Env Var 2 - found=%found%"
)
if "%found%" == "0" (
%lib_console% debug_output :enhance_path "BEFORE Env Var - PATH=!path!"
%lib_console% debug_output :enhance_path "BEFORE Env Var - PATH=%path%"
if /i "%position%" == "append" (
%lib_console% debug_output :enhance_path "Appending '%add_path%'"
set "PATH=%PATH%;%add_path%"
@ -96,11 +98,16 @@ exit /b
set "PATH=%add_path%;%PATH%"
)
%lib_console% debug_output :enhance_path "AFTER Env Var - PATH=!path!"
%lib_console% debug_output :enhance_path "AFTER Env Var - PATH=%path%"
)
:end_enhance_path
endlocal & set "PATH=%PATH:;;=;%"
rem :end_enhance_path
rem endlocal & set "PATH=%PATH:;;=;%"
set "PATH=%PATH:;;=;%"
exit /b
:set_found
if "!ERRORLEVEL!" == "0" set found=1
exit /b
:enhance_path_recursive
@ -158,26 +165,36 @@ exit /b
exit /b
)
setlocal enabledelayedexpansion
if "%depth%" == "" set depth=0
rem setlocal enabledelayedexpansion
if "%depth%" == "" set depth=0
%lib_console% debug_output :enhance_path_recursive "Env Var - add_path=%add_path%"
%lib_console% debug_output :enhance_path_recursive "Env Var - position=%position%"
%lib_console% debug_output :enhance_path_recursive "Env Var - max_depth=%max_depth%"
if %max_depth% gtr !depth! (
if %max_depth% gtr %depth% (
%lib_console% debug_output :enhance_path_recursive "Adding parent directory - '%add_path%'"
call :enhance_path "%add_path%" %position%
set /a "depth=!depth!+1"
for /d %%i in ("%add_path%\*") do (
%lib_console% debug_output :enhance_path_recursive "Env Var BEFORE - depth=!depth!"
%lib_console% debug_output :enhance_path_recursive "Found Subdirectory - '%%~fi'"
call :enhance_path_recursive "%%~fi" %max_depth% %position%
%lib_console% debug_output :enhance_path_recursive "Env Var AFTER- depth=!depth!"
)
REM set /a "depth=!depth!+1"
call :set_depth
call :loop_depth
)
:end_enhance_path_recursive
endlocal & set "PATH=%PATH%"
rem :end_enhance_path_recursive
rem endlocal & set "PATH=%PATH%"
set "PATH=%PATH%"
exit /b
: set_depth
set /a "depth=%depth%+1"
exit /b
:loop_depth
for /d %%i in ("%add_path%\*") do (
%lib_console% debug_output :enhance_path_recursive "Env Var BEFORE - depth=%depth%"
%lib_console% debug_output :enhance_path_recursive "Found Subdirectory - '%%~fi'"
call :enhance_path_recursive "%%~fi" %max_depth% %position%
%lib_console% debug_output :enhance_path_recursive "Env Var AFTER- depth=%depth%"
)
exit /b