From 373917d00288a98af97882e093cf050ddc0c8912 Mon Sep 17 00:00:00 2001 From: Rootiest Date: Mon, 21 Sep 2026 21:26:52 -0400 Subject: [PATCH] fix(functions): stop routing deterministic cd through zoxide's shadow Verified an agy audit of every bare cd call by hand. conf.d/zoxide.fish gates alias cd=z behind status is-interactive plus the C1 toggle, and _zoxide_hook fires on --on-variable PWD, so it tracks a directory change no matter how PWD got there -- switching to builtin cd loses zoxide's frecency tracking nothing. mkcd.fish's single cd and mkrep.fish's 9 (entering the new repo, plus 8 rollback-to-original-directory sites on error paths and --no-cd) were both intended as exact, deterministic path navigation, never a zoxide query. The real risk was mkrep's rollback path: if $orig_pwd ever failed cd's own -d check for any reason, z's fallback branch queries zoxide for a *guessed* frecent directory instead -- landing a failed run's cleanup in a directory the caller never asked for, not the one it was trying to return to. All 9 sites now use builtin cd. Corrected both functions' CLASSIFICATION from uses-shadow(cd) to bypasses-shadow(cd) -- neither wanted zoxide's query, they were tagged that way only because the header audit recorded what the code was doing at the time, not what it needed. integrations/fzf.fish's fzf-alt-c-widget also calls bare cd, but it's vendored upstream code (PatrickF1/fzf.fish) and is itself an interactive directory-jump binding, not a script/automation caller -- left alone, same as fisher.fish's rm calls. --- functions/mkcd.fish | 4 ++-- functions/mkrep.fish | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/functions/mkcd.fish b/functions/mkcd.fish index 161a77a..e8173d3 100644 --- a/functions/mkcd.fish +++ b/functions/mkcd.fish @@ -5,7 +5,7 @@ # 01-file-and-directory # # CLASSIFICATION -# uses-shadow(cd) +# bypasses-shadow(cd) # # SYNOPSIS # mkcd [-s | --silent] @@ -68,7 +68,7 @@ function mkcd --description 'Create a directory (with parents) and cd into it' _fish_mkdir_p --tree $dir; or return $status end - cd $dir + builtin cd $dir or return $status if test $is_new -eq 1 diff --git a/functions/mkrep.fish b/functions/mkrep.fish index 725ba33..e12bb51 100644 --- a/functions/mkrep.fish +++ b/functions/mkrep.fish @@ -10,7 +10,7 @@ # _mkrep_repo_exists, git # # CLASSIFICATION -# uses-shadow(cd), destructive, network +# bypasses-shadow(cd), destructive, network # # SYNOPSIS # mkrep [--cd | --no-cd] [--mkdir | --no-mkdir] [--git | --no-git] @@ -307,7 +307,7 @@ function mkrep --description 'Create a directory, cd into it, and git init it' _mkrep_say $silent "$c_warn""→$c_reset $c_arg$dir$c_reset already exists" end - cd $dir + builtin cd $dir or begin echo "$c_err""✘$c_reset Failed to enter $c_arg$dir$c_reset" >&2 return 1 @@ -329,7 +329,7 @@ function mkrep --description 'Create a directory, cd into it, and git init it' end or begin echo "$c_err""✘$c_reset git init failed in $c_arg$dir$c_reset" >&2 - cd $orig_pwd + builtin cd $orig_pwd return 1 end @@ -344,7 +344,7 @@ function mkrep --description 'Create a directory, cd into it, and git init it' _mkrep_verbose $silent $verbose "$c_dim""Running: git remote add origin $_flag_remote$c_reset" _mkrep_add_origin $silent $_flag_remote or begin - cd $orig_pwd + builtin cd $orig_pwd return 1 end end @@ -354,7 +354,7 @@ function mkrep --description 'Create a directory, cd into it, and git init it' test -z "$cmd"; and set cmd $MKREP_REMOTE_CMD if test -z "$cmd" echo "$c_err""✘$c_reset --new-remote given no command and \$MKREP_REMOTE_CMD is unset" >&2 - cd $orig_pwd + builtin cd $orig_pwd return 1 end @@ -371,7 +371,7 @@ function mkrep --description 'Create a directory, cd into it, and git init it' end or begin echo "$c_err""✘$c_reset Remote-create command failed" >&2 - cd $orig_pwd + builtin cd $orig_pwd return 1 end _mkrep_say $silent "$c_ok""✔$c_reset Ran remote-create command" @@ -393,7 +393,7 @@ function mkrep --description 'Create a directory, cd into it, and git init it' _mkrep_say $silent "$c_warn""→$c_reset $c_arg$USER/$name$c_reset already exists on $srv_type; linking instead of creating" _mkrep_add_origin $silent $url or begin - cd $orig_pwd + builtin cd $orig_pwd return 1 end else @@ -424,7 +424,7 @@ function mkrep --description 'Create a directory, cd into it, and git init it' if string match -q '*{server}*' -- $cmd if test -z "$srv_url" echo "$c_err""✘$c_reset No base URL resolved for $srv_type (set \$GITEA_URL/\$GITEA_HOST or \$GITLAB_URL/\$GITLAB_HOST)" >&2 - cd $orig_pwd + builtin cd $orig_pwd return 1 end set cmd (string replace -a '{server}' $srv_url -- $cmd) @@ -440,7 +440,7 @@ function mkrep --description 'Create a directory, cd into it, and git init it' end or begin echo "$c_err""✘$c_reset Remote-create command failed" >&2 - cd $orig_pwd + builtin cd $orig_pwd return 1 end set -l url (_mkrep_remote_url $srv_type $USER $name $srv_url) @@ -451,7 +451,7 @@ function mkrep --description 'Create a directory, cd into it, and git init it' end if test $do_cd -eq 0 - cd $orig_pwd + builtin cd $orig_pwd else _mkrep_say $silent "$c_ok""✔$c_reset Entered $c_arg$dir$c_reset" end