From edfcd38b1449f3afa0c0ccabe10c93ba0538758a Mon Sep 17 00:00:00 2001 From: "@zimeg" Date: Sun, 3 Nov 2024 04:56:00 -0800 Subject: [PATCH] fix: set the exit code to the return of cd for the warp function --- test/tests.sh | 3 +++ wd.sh | 3 +++ 2 files changed, 6 insertions(+) diff --git a/test/tests.sh b/test/tests.sh index 296e333..2243427 100755 --- a/test/tests.sh +++ b/test/tests.sh @@ -119,6 +119,9 @@ test_wd_point() wd -q moon assertFalse "should fail to warp to a point that does not exist" \ "$pipestatus" + wd -q "$WD_TEST_DIR" pluto 2&> /dev/null + assertFalse "should fail warping to nonexistent nested directories" \ + "$pipestatus" command rm -rf "$WD_TEST_DIR" } diff --git a/wd.sh b/wd.sh index 1327914..d7d5bc9 100755 --- a/wd.sh +++ b/wd.sh @@ -145,14 +145,17 @@ wd_warp() else (( n = $#1 - 1 )) cd -$n > /dev/null + WD_EXIT_CODE=$? fi elif [[ ${points[$point]} != "" ]] then if [[ $sub != "" ]] then cd ${points[$point]/#\~/$HOME}/$sub + WD_EXIT_CODE=$? else cd ${points[$point]/#\~/$HOME} + WD_EXIT_CODE=$? fi else wd_exit_fail "Unknown warp point '${point}'"