From 1cb8f86d08c46e596b67de884a133e2a01fe0358 Mon Sep 17 00:00:00 2001 From: phanium Date: Sat, 3 Aug 2024 21:18:36 +0800 Subject: [PATCH] fix(fish): reset status code before `set` `set` will preserve the exit status of the last command https://github.com/fish-shell/fish-shell/issues/3651 --- templates/fish.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/templates/fish.txt b/templates/fish.txt index 4882280..9448fc5 100644 --- a/templates/fish.txt +++ b/templates/fish.txt @@ -84,7 +84,9 @@ function __zoxide_z __zoxide_cd $argv[1] else if test $argc -eq 2 -a $argv[1] = -- __zoxide_cd -- $argv[2] - else if set -l result (string replace --regex -- $__zoxide_z_prefix_regex '' $argv[-1]); and test -n $result + else if true; and set -l result (string replace --regex -- $__zoxide_z_prefix_regex '' $argv[-1]); and test -n $result + # `set` will preserve the exit status of the last command + # https://github.com/fish-shell/fish-shell/issues/3651 __zoxide_cd $result else set -l result (command zoxide query --exclude (__zoxide_pwd) -- $argv)