This commit is contained in:
David Refoua 2024-11-14 00:08:31 +03:30
commit d15e7ac69f
3 changed files with 39 additions and 26 deletions

14
vendor/bin/excd.cmd vendored
View File

@ -1,6 +1,8 @@
@if "%~1"=="/?" (@cd %*)
@set excd=%*
@set excd=%excd:"=%
@if "%excd:~0,1%"=="~" (@set excd=%userprofile%\%excd:~1%)
@if not "%~1"=="/d" (@set excd_param="/d") else (@set excd_param=)
@cd %excd_param% "%excd%"
@echo off
set excd=%*
set excd=%excd:"=%
set excd_param=/d
if /i "%excd:~0,2%"=="/d" set "excd=%excd:~2%"
if "%excd:~0,1%"=="~" (set excd=%userprofile%\%excd:~1%)
if "%excd:~0,1%"=="/" (set excd_param=)
cd %excd_param% %excd%

2
vendor/init.bat vendored
View File

@ -478,7 +478,7 @@ if "%CMDER_ALIASES%" == "1" (
)
:: Add aliases to the environment
type "%user_aliases%" | findstr /b /l /i "history=cat " >nul
type "%user_aliases%" | %WINDIR%\System32\findstr /b /l /i "history=cat " >nul
if "%ERRORLEVEL%" == "0" (
echo Migrating alias 'history' to new Clink 1.x.x...
call "%CMDER_ROOT%\vendor\bin\alias.cmd" /d history

View File

@ -1,6 +1,5 @@
@echo off
call "%~dp0lib_base.cmd"
call "%%~dp0lib_console"
set lib_path=call "%~dp0lib_path.cmd"
@ -11,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
@ -32,13 +38,12 @@ exit /b
:::options:
:::
::: append <in> Append to the path env variable rather than pre-pend.
::B
:::
:::
:::output:
:::
::: path <out> Sets the path env variable if required.
:::-------------------------------------------------------------------------------
if "%~1" neq "" (
set "add_path=%~1"
) else (
@ -52,7 +57,8 @@ exit /b
set "position="
)
dir "%add_path%" | 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%"
) else (
@ -81,20 +87,20 @@ exit /b
echo "!path!"|!WINDIR!\System32\findstr >nul /I /R /C:";!find_query!;"
call :set_found
)
%print_debug% :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
)
%print_debug% :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
)
%print_debug% :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%
@ -129,13 +135,12 @@ exit /b
exit /b
:changed
%print_debug% :enhance_path "END Env Var - PATH=%path%"
%print_debug% :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%"
exit /b
exit /b
:set_found
if "%ERRORLEVEL%" == "0" (
set found=1
@ -190,7 +195,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%"
@ -204,7 +209,7 @@ exit /b
set "path=%path%;%add_to_path%"
) else (
set "path=%add_to_path%;%path%"
)
)
)
)
@ -213,10 +218,10 @@ exit /b
exit /b
)
%print_debug% :set_path_recursive "Env Var - add_path=%add_to_path%"
%print_debug% :set_path_recursive "Env Var - position=%position%"
%print_debug% :set_path_recursive "Env Var - depth=%depth%"
%print_debug% :set_path_recursive "Env Var - max_depth=%max_depth%"
%print_debug% :set_path_recursive "Env Var - add_path=%add_to_path%"
%print_debug% :set_path_recursive "Env Var - position=%position%"
%print_debug% :set_path_recursive "Env Var - depth=%depth%"
%print_debug% :set_path_recursive "Env Var - max_depth=%max_depth%"
if %max_depth% gtr %depth% (
if "%add_to_path%" neq "" (
@ -225,7 +230,7 @@ exit /b
set "path=%path%;%add_to_path%"
) else (
set "path=%add_to_path%;%path%"
)
)
)
call :set_depth
call :loop_depth
@ -235,7 +240,7 @@ exit /b
exit /b
: set_depth
:set_depth
set /a "depth=%depth%+1"
exit /b
@ -245,10 +250,16 @@ exit /b
)
for /d %%i in ("%add_path%\*") do (
<<<<<<< HEAD
%print_debug% :set_path_recursive "Env Var BEFORE - depth=%depth%"
%print_debug% :set_path_recursive "Found Subdirectory - '%%~fi'"
call :set_path_recursive "%%~fi" %depth% %max_depth% %position%
%print_debug% :set_path_recursive "Env Var AFTER- depth=%depth%"
=======
%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%
%print_debug% :enhance_path_recursive "Env Var AFTER- depth=%depth%"
>>>>>>> 126347025f9cade241beff182738b2527da7535e
)
exit /b