mirror of
https://github.com/cmderdev/cmder.git
synced 2025-07-05 03:23:39 +08:00
Speed up calls to lib_console
This commit is contained in:
34
vendor/lib/lib_path.cmd
vendored
34
vendor/lib/lib_path.cmd
vendored
@ -42,7 +42,7 @@ exit /b
|
||||
if "%~1" neq "" (
|
||||
set "add_path=%~1"
|
||||
) else (
|
||||
%lib_console% show_error "You must specify a directory to add to the path!"
|
||||
%print_error% "You must specify a directory to add to the path!"
|
||||
exit 1
|
||||
)
|
||||
|
||||
@ -81,29 +81,29 @@ exit /b
|
||||
echo "!path!"|!WINDIR!\System32\findstr >nul /I /R /C:";!find_query!;"
|
||||
call :set_found
|
||||
)
|
||||
!lib_console! debug_output :enhance_path "Env Var INSIDE PATH !find_query! - found=!found!"
|
||||
!print_debug! :enhance_path "Env Var INSIDE PATH !find_query! - found=!found!"
|
||||
|
||||
if /i "!position!" == "append" (
|
||||
if "!found!" == "0" (
|
||||
echo "!path!"|!WINDIR!\System32\findstr >nul /I /R /C:";!find_query!\"$"
|
||||
call :set_found
|
||||
)
|
||||
!lib_console! debug_output :enhance_path "Env Var END PATH !find_query! - found=!found!"
|
||||
!print_debug! :enhance_path "Env Var END PATH !find_query! - found=!found!"
|
||||
) else (
|
||||
if "!found!" == "0" (
|
||||
echo "!path!"|!WINDIR!\System32\findstr >nul /I /R /C:"^\"!find_query!;"
|
||||
call :set_found
|
||||
)
|
||||
!lib_console! debug_output :enhance_path "Env Var BEGIN PATH !find_query! - found=!found!"
|
||||
!print_debug! :enhance_path "Env Var BEGIN PATH !find_query! - found=!found!"
|
||||
)
|
||||
endlocal & set found=%found%
|
||||
|
||||
if "%found%" == "0" (
|
||||
if /i "%position%" == "append" (
|
||||
%lib_console% debug_output :enhance_path "Appending '%add_to_path%'"
|
||||
%print_debug% :enhance_path "Appending '%add_to_path%'"
|
||||
set "PATH=%PATH%;%add_to_path%"
|
||||
) else (
|
||||
%lib_console% debug_output :enhance_path "Prepending '%add_to_path%'"
|
||||
%print_debug% :enhance_path "Prepending '%add_to_path%'"
|
||||
set "PATH=%add_to_path%;%PATH%"
|
||||
)
|
||||
|
||||
@ -113,8 +113,8 @@ exit /b
|
||||
:end_enhance_path
|
||||
set "PATH=%PATH:;;=;%"
|
||||
if NOT "%OLD_PATH%" == "%PATH%" (
|
||||
%lib_console% debug_output :enhance_path "END Env Var - PATH=%path%"
|
||||
%lib_console% debug_output :enhance_path "Env Var %find_query% - found=%found%"
|
||||
%print_debug% :enhance_path "END Env Var - PATH=%path%"
|
||||
%print_debug% :enhance_path "Env Var %find_query% - found=%found%"
|
||||
)
|
||||
set "position="
|
||||
exit /b
|
||||
@ -156,7 +156,7 @@ exit /b
|
||||
if "%~1" neq "" (
|
||||
set "add_path=%~1"
|
||||
) else (
|
||||
%lib_console% show_error "You must specify a directory to add to the path!"
|
||||
%print_error% "You must specify a directory to add to the path!"
|
||||
exit 1
|
||||
)
|
||||
|
||||
@ -188,14 +188,14 @@ exit /b
|
||||
exit /b
|
||||
)
|
||||
|
||||
%lib_console% debug_output :enhance_path_recursive "Env Var - add_path=%add_to_path%"
|
||||
%lib_console% debug_output :enhance_path_recursive "Env Var - position=%position%"
|
||||
%lib_console% debug_output :enhance_path_recursive "Env Var - depth=%depth%"
|
||||
%lib_console% debug_output :enhance_path_recursive "Env Var - max_depth=%max_depth%"
|
||||
%print_debug% :enhance_path_recursive "Env Var - add_path=%add_to_path%"
|
||||
%print_debug% :enhance_path_recursive "Env Var - position=%position%"
|
||||
%print_debug% :enhance_path_recursive "Env Var - depth=%depth%"
|
||||
%print_debug% :enhance_path_recursive "Env Var - max_depth=%max_depth%"
|
||||
|
||||
if %max_depth% gtr %depth% (
|
||||
if "%add_to_path%" neq "" (
|
||||
%lib_console% debug_output :enhance_path_recursive "Adding parent directory - '%add_to_path%'"
|
||||
%print_debug% :enhance_path_recursive "Adding parent directory - '%add_to_path%'"
|
||||
call :enhance_path "%add_to_path%" %position%
|
||||
)
|
||||
call :set_depth
|
||||
@ -216,10 +216,10 @@ exit /b
|
||||
)
|
||||
|
||||
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'"
|
||||
%print_debug% :enhance_path_recursive "Env Var BEFORE - depth=%depth%"
|
||||
%print_debug% :enhance_path_recursive "Found Subdirectory - '%%~fi'"
|
||||
call :enhance_path_recursive "%%~fi" %depth% %max_depth% %position%
|
||||
%lib_console% debug_output :enhance_path_recursive "Env Var AFTER- depth=%depth%"
|
||||
%print_debug% :enhance_path_recursive "Env Var AFTER- depth=%depth%"
|
||||
)
|
||||
exit /b
|
||||
|
||||
|
Reference in New Issue
Block a user