From 504fa459d71e22ee329f3d7658ee2ed84c70e809 Mon Sep 17 00:00:00 2001 From: phanirithvij Date: Sat, 29 Jan 2022 13:13:49 +0530 Subject: [PATCH 1/3] cmd: don't ignore _ZL_CD and allow relative paths --- z.cmd | 17 ++++++++++++++++- z.lua | 17 ++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/z.cmd b/z.cmd index f632aea..01004ea 100644 --- a/z.cmd +++ b/z.cmd @@ -98,6 +98,11 @@ for /f "delims=" %%i in ('cd') do set "PWD=%%i" if /i "%RunMode%"=="-n" ( for /f "delims=" %%i in ('call "%LuaExe%" "%LuaScript%" --cd %MatchType% %StrictSub% %InterMode% %*') do set "NewPath=%%i" + if "!NewPath!"=="" ( + set NewPath=%1 + call :normalizepath !NewPath! + set NewPath=!retval! + ) if not "!NewPath!"=="" ( if exist !NewPath!\nul ( if /i not "%_ZL_ECHO%"=="" ( @@ -107,6 +112,8 @@ if /i "%RunMode%"=="-n" ( pushd !NewPath! endlocal goto popdir + ) else ( + echo The system cannot find the path specified. ) ) ) else ( @@ -121,8 +128,16 @@ rem -- directory without leaking a pushd. popd setlocal set NewPath=%CD% -endlocal & popd & cd /d "%NewPath%" +set "CDCmd=cd /d" +if /i not "%_ZL_CD%"=="" ( + set "CDCmd=%_ZL_CD%" +) +endlocal & popd & %CDCmd% "%NewPath%" :end echo. +exit /B +:normalizepath +set retval=%~f1 +exit /B diff --git a/z.lua b/z.lua index ca912ef..1ab0c27 100755 --- a/z.lua +++ b/z.lua @@ -2544,6 +2544,11 @@ if /i "%1"=="" ( for /f "delims=" %%i in ('cd') do set "PWD=%%i" if /i "%RunMode%"=="-n" ( for /f "delims=" %%i in ('call "%LuaExe%" "%LuaScript%" --cd %MatchType% %StrictSub% %InterMode% %*') do set "NewPath=%%i" + if "!NewPath!"=="" ( + set NewPath=%1 + call :normalizepath !NewPath! + set NewPath=!retval! + ) if not "!NewPath!"=="" ( if exist !NewPath!\nul ( if /i not "%_ZL_ECHO%"=="" ( @@ -2553,6 +2558,8 @@ if /i "%RunMode%"=="-n" ( pushd !NewPath! endlocal goto popdir + ) else ( + echo The system cannot find the path specified. ) ) ) else ( @@ -2563,8 +2570,16 @@ goto end popd setlocal set "NewPath=%CD%" -endlocal & popd & cd /d "%NewPath%" +set "CDCmd=cd /d" +if /i not "%_ZL_CD%"=="" ( + set "CDCmd=%_ZL_CD%" +) +endlocal & popd & %CDCmd% "%NewPath%" :end +exit /B +:normalizepath +set retval=%~f1 +exit /B ]] From 08b29e9612d15fb0921ba20ff30a5f708081d42c Mon Sep 17 00:00:00 2001 From: Phani Rithvij Date: Sat, 29 Jan 2022 14:13:07 +0530 Subject: [PATCH 2/3] Update z.cmd --- z.cmd | 2 -- 1 file changed, 2 deletions(-) diff --git a/z.cmd b/z.cmd index 01004ea..8d64f7f 100644 --- a/z.cmd +++ b/z.cmd @@ -112,8 +112,6 @@ if /i "%RunMode%"=="-n" ( pushd !NewPath! endlocal goto popdir - ) else ( - echo The system cannot find the path specified. ) ) ) else ( From dad86b5dddeafa5a21ff739621d9e387fadf6cb0 Mon Sep 17 00:00:00 2001 From: Phani Rithvij Date: Sat, 29 Jan 2022 14:13:57 +0530 Subject: [PATCH 3/3] Update z.lua --- z.lua | 2 -- 1 file changed, 2 deletions(-) diff --git a/z.lua b/z.lua index 1ab0c27..b2b8803 100755 --- a/z.lua +++ b/z.lua @@ -2558,8 +2558,6 @@ if /i "%RunMode%"=="-n" ( pushd !NewPath! endlocal goto popdir - ) else ( - echo The system cannot find the path specified. ) ) ) else (