From 42315d8cecab61757530d709f63d1c135f8a6a5b Mon Sep 17 00:00:00 2001 From: David Refoua Date: Fri, 18 Oct 2024 03:18:17 +0330 Subject: [PATCH 1/6] enable `/d` flag in `excd` by default --- vendor/bin/excd.cmd | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/vendor/bin/excd.cmd b/vendor/bin/excd.cmd index c957740..a4ac4bd 100644 --- a/vendor/bin/excd.cmd +++ b/vendor/bin/excd.cmd @@ -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% From 25ccfeed772ab3060096d966c78a68aa370ba50a Mon Sep 17 00:00:00 2001 From: David Refoua Date: Wed, 13 Nov 2024 23:08:13 +0330 Subject: [PATCH 2/6] prevent warnings if the dir does not exist https://github.com/cmderdev/cmder/issues/121#issuecomment-654171568 --- vendor/lib/lib_path.cmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/lib/lib_path.cmd b/vendor/lib/lib_path.cmd index d9f229b..33386f7 100644 --- a/vendor/lib/lib_path.cmd +++ b/vendor/lib/lib_path.cmd @@ -52,7 +52,7 @@ exit /b set "position=" ) - dir "%add_path%" | findstr -i "\.COM \.EXE \.BAT \.CMD \.PS1 \.VBS" >NUL + dir "%add_path%" 2>NUL | findstr -i "\.COM \.EXE \.BAT \.CMD \.PS1 \.VBS" >NUL if "%ERRORLEVEL%" == "0" ( set "add_to_path=%add_path%" ) else ( From 4d15730d05698fbb691ce80e264d44a3ea5a99a4 Mon Sep 17 00:00:00 2001 From: David Refoua Date: Wed, 13 Nov 2024 23:12:59 +0330 Subject: [PATCH 3/6] cleanup --- vendor/lib/lib_path.cmd | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/vendor/lib/lib_path.cmd b/vendor/lib/lib_path.cmd index 33386f7..36f4fb1 100644 --- a/vendor/lib/lib_path.cmd +++ b/vendor/lib/lib_path.cmd @@ -1,6 +1,5 @@ @echo off - call "%~dp0lib_base.cmd" call "%%~dp0lib_console" set lib_path=call "%~dp0lib_path.cmd" @@ -32,13 +31,12 @@ exit /b :::options: ::: ::: append Append to the path env variable rather than pre-pend. -::B +::: ::: :::output: ::: ::: path Sets the path env variable if required. :::------------------------------------------------------------------------------- - if "%~1" neq "" ( set "add_path=%~1" ) else ( @@ -53,6 +51,7 @@ exit /b ) dir "%add_path%" 2>NUL | findstr -i "\.COM \.EXE \.BAT \.CMD \.PS1 \.VBS" >NUL + if "%ERRORLEVEL%" == "0" ( set "add_to_path=%add_path%" ) else ( @@ -135,7 +134,6 @@ exit /b exit /b - :set_found if "%ERRORLEVEL%" == "0" ( set found=1 @@ -223,7 +221,7 @@ exit /b exit /b -: set_depth +:set_depth set /a "depth=%depth%+1" exit /b @@ -239,4 +237,3 @@ exit /b %print_debug% :enhance_path_recursive "Env Var AFTER- depth=%depth%" ) exit /b - From 510178852d074c8f3d4c01c06585b6bb81cfa064 Mon Sep 17 00:00:00 2001 From: David Refoua Date: Wed, 13 Nov 2024 23:58:11 +0330 Subject: [PATCH 4/6] add missing qualified dir https://github.com/cmderdev/cmder/pull/1961 --- vendor/init.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/init.bat b/vendor/init.bat index 1799ae4..583e0e9 100644 --- a/vendor/init.bat +++ b/vendor/init.bat @@ -426,7 +426,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 From 7ceacb63ddaa08f41fc92020a99f659f561df3e3 Mon Sep 17 00:00:00 2001 From: David Refoua Date: Thu, 14 Nov 2024 00:00:53 +0330 Subject: [PATCH 5/6] respect PATHEXT instead of hardcoding our own value * support other path extensions as well (e.g. `.py` commonly used) --- vendor/lib/lib_path.cmd | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/vendor/lib/lib_path.cmd b/vendor/lib/lib_path.cmd index 36f4fb1..e91efab 100644 --- a/vendor/lib/lib_path.cmd +++ b/vendor/lib/lib_path.cmd @@ -10,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 @@ -50,7 +57,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%" @@ -184,7 +191,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%" From 126347025f9cade241beff182738b2527da7535e Mon Sep 17 00:00:00 2001 From: David Refoua Date: Thu, 14 Nov 2024 00:01:29 +0330 Subject: [PATCH 6/6] cleanup --- vendor/lib/lib_path.cmd | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/vendor/lib/lib_path.cmd b/vendor/lib/lib_path.cmd index e91efab..04f1cf3 100644 --- a/vendor/lib/lib_path.cmd +++ b/vendor/lib/lib_path.cmd @@ -87,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% @@ -135,8 +135,8 @@ 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 @@ -210,10 +210,10 @@ exit /b exit /b ) - %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%" + %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 "" ( @@ -238,9 +238,9 @@ exit /b ) for /d %%i in ("%add_path%\*") do ( - %print_debug% :enhance_path_recursive "Env Var BEFORE - 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%" + %print_debug% :enhance_path_recursive "Env Var AFTER- depth=%depth%" ) exit /b