Skip to content

Commit

Permalink
fix: set the exit code to the return of cd for the warp function
Browse files Browse the repository at this point in the history
  • Loading branch information
zimeg committed Nov 3, 2024
1 parent 09f0c25 commit edfcd38
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions test/tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

Expand Down
3 changes: 3 additions & 0 deletions wd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}'"
Expand Down

0 comments on commit edfcd38

Please sign in to comment.