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.
This commit is contained in:
+2
-2
@@ -5,7 +5,7 @@
|
|||||||
# 01-file-and-directory
|
# 01-file-and-directory
|
||||||
#
|
#
|
||||||
# CLASSIFICATION
|
# CLASSIFICATION
|
||||||
# uses-shadow(cd)
|
# bypasses-shadow(cd)
|
||||||
#
|
#
|
||||||
# SYNOPSIS
|
# SYNOPSIS
|
||||||
# mkcd [-s | --silent] <dir>
|
# mkcd [-s | --silent] <dir>
|
||||||
@@ -68,7 +68,7 @@ function mkcd --description 'Create a directory (with parents) and cd into it'
|
|||||||
_fish_mkdir_p --tree $dir; or return $status
|
_fish_mkdir_p --tree $dir; or return $status
|
||||||
end
|
end
|
||||||
|
|
||||||
cd $dir
|
builtin cd $dir
|
||||||
or return $status
|
or return $status
|
||||||
|
|
||||||
if test $is_new -eq 1
|
if test $is_new -eq 1
|
||||||
|
|||||||
+10
-10
@@ -10,7 +10,7 @@
|
|||||||
# _mkrep_repo_exists, git
|
# _mkrep_repo_exists, git
|
||||||
#
|
#
|
||||||
# CLASSIFICATION
|
# CLASSIFICATION
|
||||||
# uses-shadow(cd), destructive, network
|
# bypasses-shadow(cd), destructive, network
|
||||||
#
|
#
|
||||||
# SYNOPSIS
|
# SYNOPSIS
|
||||||
# mkrep [--cd | --no-cd] [--mkdir | --no-mkdir] [--git | --no-git]
|
# 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"
|
_mkrep_say $silent "$c_warn""→$c_reset $c_arg$dir$c_reset already exists"
|
||||||
end
|
end
|
||||||
|
|
||||||
cd $dir
|
builtin cd $dir
|
||||||
or begin
|
or begin
|
||||||
echo "$c_err""✘$c_reset Failed to enter $c_arg$dir$c_reset" >&2
|
echo "$c_err""✘$c_reset Failed to enter $c_arg$dir$c_reset" >&2
|
||||||
return 1
|
return 1
|
||||||
@@ -329,7 +329,7 @@ function mkrep --description 'Create a directory, cd into it, and git init it'
|
|||||||
end
|
end
|
||||||
or begin
|
or begin
|
||||||
echo "$c_err""✘$c_reset git init failed in $c_arg$dir$c_reset" >&2
|
echo "$c_err""✘$c_reset git init failed in $c_arg$dir$c_reset" >&2
|
||||||
cd $orig_pwd
|
builtin cd $orig_pwd
|
||||||
return 1
|
return 1
|
||||||
end
|
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_verbose $silent $verbose "$c_dim""Running: git remote add origin $_flag_remote$c_reset"
|
||||||
_mkrep_add_origin $silent $_flag_remote
|
_mkrep_add_origin $silent $_flag_remote
|
||||||
or begin
|
or begin
|
||||||
cd $orig_pwd
|
builtin cd $orig_pwd
|
||||||
return 1
|
return 1
|
||||||
end
|
end
|
||||||
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
|
test -z "$cmd"; and set cmd $MKREP_REMOTE_CMD
|
||||||
if test -z "$cmd"
|
if test -z "$cmd"
|
||||||
echo "$c_err""✘$c_reset --new-remote given no command and \$MKREP_REMOTE_CMD is unset" >&2
|
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
|
return 1
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -371,7 +371,7 @@ function mkrep --description 'Create a directory, cd into it, and git init it'
|
|||||||
end
|
end
|
||||||
or begin
|
or begin
|
||||||
echo "$c_err""✘$c_reset Remote-create command failed" >&2
|
echo "$c_err""✘$c_reset Remote-create command failed" >&2
|
||||||
cd $orig_pwd
|
builtin cd $orig_pwd
|
||||||
return 1
|
return 1
|
||||||
end
|
end
|
||||||
_mkrep_say $silent "$c_ok""✔$c_reset Ran remote-create command"
|
_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_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
|
_mkrep_add_origin $silent $url
|
||||||
or begin
|
or begin
|
||||||
cd $orig_pwd
|
builtin cd $orig_pwd
|
||||||
return 1
|
return 1
|
||||||
end
|
end
|
||||||
else
|
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 string match -q '*{server}*' -- $cmd
|
||||||
if test -z "$srv_url"
|
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
|
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
|
return 1
|
||||||
end
|
end
|
||||||
set cmd (string replace -a '{server}' $srv_url -- $cmd)
|
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
|
end
|
||||||
or begin
|
or begin
|
||||||
echo "$c_err""✘$c_reset Remote-create command failed" >&2
|
echo "$c_err""✘$c_reset Remote-create command failed" >&2
|
||||||
cd $orig_pwd
|
builtin cd $orig_pwd
|
||||||
return 1
|
return 1
|
||||||
end
|
end
|
||||||
set -l url (_mkrep_remote_url $srv_type $USER $name $srv_url)
|
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
|
end
|
||||||
|
|
||||||
if test $do_cd -eq 0
|
if test $do_cd -eq 0
|
||||||
cd $orig_pwd
|
builtin cd $orig_pwd
|
||||||
else
|
else
|
||||||
_mkrep_say $silent "$c_ok""✔$c_reset Entered $c_arg$dir$c_reset"
|
_mkrep_say $silent "$c_ok""✔$c_reset Entered $c_arg$dir$c_reset"
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user