cd alias (zd) sends `cd -- dir` and `cd -P dir` to zoxide, breaks `$(cd -- dir && pwd)` in sourced scripts
The cd alias (zd in default/bash/aliases) only checks whether $1 is a directory. When the first argument is an option like -- or -P, it goes to zoxide instead of builtin cd. That breaks the common script idiom $(cd -- "$dir" && pwd) in anything sourced from an interactive shell.
Repro
x=$(cd -- /tmp && pwd); printf '[%s]\n' "$x"
# [ /tmp
# /tmp]
y=$(cd -P /tmp && pwd); printf '[%s]\n' "$y"
# zoxide: no match found
# [Error: Directory not found]
Expected [/tmp] in both cases.
Where it bit me
Ran into this with Aikido safe-chain. Its init-posix.sh gets sourced from ~/.bashrc and finds its own directory with CDPATH= cd -- "$(dirname ...)" && pwd -P. With the alias, the icon line ended up inside the PATH entry, so safe-chain was never found and its npm/pip/uv wrappers quietly fell back to running unprotected. No error, just a security tool that did nothing. Other tools that source a helper with the same idiom (nvm-style installers, completion scripts) will hit the same thing.
Possible fix
Send anything that starts with - to builtin cd, and only use zoxide for plain non-directory arguments:
zd() {
if (( $# == 0 )); then
builtin cd ~ || return
elif [[ $1 == -* && $1 != - ]] || [[ -d $1 ]]; then
builtin cd "$@" || return
else
...
(cd - is left out on purpose, so it still goes through zoxide like today.) For now I override zd in my ~/.bashrc, so I can send a PR if that shape works for you.
omarchy-dev 4.0.0.r7608.g14abc07, bash 5.3.20, zoxide 0.10.0.
GPT-6 in Codex (effort setting not exposed) read the report and the current default/bash/aliases. No worker tests ran: the classification reviewer, deepseek-v4p1-flash, returned no usable class, so classification remains unsettled. This is waiting for another classification review before verification can proceed.
GPT-6 in Codex (reasoning effort not exposed) checked the stock Bash startup and zd on current quattro: -- and -P still go to zoxide, and the wrapper adds output that contaminates command substitution. #18013 routes both forms to builtin cd and already links this issue.
Opus 5.5 High and muse-wonder via pi, thinking high agreed with that source diagnosis; independence is not guaranteed. No tests ran in this issue session; #18013 records its separate worker reproduction and passing checks. The reported safe-chain fallback was not independently checked. This issue is waiting on the maintainer’s decision on #18013.