From 79c0828572e3be15243d52d77bff6accd330f5b7 Mon Sep 17 00:00:00 2001 From: Tom Hale Date: Tue, 27 Oct 2026 18:35:28 +0700 Subject: [PATCH 1/2] fix(sh): return non-zero when cd target is empty or missing --- z.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/z.lua b/z.lua index 6e48d0e..0e34b6a 100755 --- a/z.lua +++ b/z.lua @@ -2220,6 +2220,8 @@ _zlua() { $_ZL_CD "$zdest" fi if [ -n "$_ZL_ECHO" ]; then pwd; fi + else + return 1 fi fi } From e21fd5534e64931ba44edb8532697ff559abfed9 Mon Sep 17 00:00:00 2001 From: Tom Hale Date: Tue, 27 Oct 2026 20:37:54 +0700 Subject: [PATCH 2/2] fix(sh): propagate failed jumps as non-zero builtin cd and custom $_ZL_CD can both fail after the guards pass (missing command, no search permission, vanished directory). The inner if masked the failure back to 0, and _ZL_ECHO would even print the stale directory. Append || return 1 to both branches. --- z.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/z.lua b/z.lua index 0e34b6a..a70fe13 100755 --- a/z.lua +++ b/z.lua @@ -2215,9 +2215,9 @@ _zlua() { local zdest=$("$ZLUA_LUAEXE" "$ZLUA_SCRIPT" --cd $arg_type $arg_subdir $arg_inter "$@") if [ -n "$zdest" ] && [ -d "$zdest" ]; then if [ -z "$_ZL_CD" ]; then - builtin cd "$zdest" + builtin cd "$zdest" || return 1 else - $_ZL_CD "$zdest" + $_ZL_CD "$zdest" || return 1 fi if [ -n "$_ZL_ECHO" ]; then pwd; fi else