fix(shell): keep a user's claude/codex function when the cwd has a matching entry (#39820)

command -v prints a shell function's bare name, so a claude/codex directory
or executable in the cwd passed the -x check and Orca replaced the user's
function. Skip the wrapper when a function with that name is already defined.

STA-13246
This commit is contained in:
Neil
2026-11-08 03:23:55 -08:00
committed by GitHub
parent 40236ab701
commit b746eef069
4 changed files with 45 additions and 4 deletions
+2 -1
View File
@@ -34,7 +34,8 @@ export function getPosixCodexShellLaunchPreflight(): string {
# Why || : twice — zsh alone aborts inside the substitution, but every shell's
# assignment adopts its exit status, so an absent codex trips set -e in bash too.
__orca_codex_binary="$(unalias codex 2>/dev/null || :; command -v codex 2>/dev/null || :)"
if [[ -n "\${__orca_codex_binary:-}" && -x "\${__orca_codex_binary}" ]]; then
# Why typeset -f: a user's own codex function wins; command -v prints its bare name, which -x tests against the cwd.
if ! typeset -f codex >/dev/null 2>&1 && [[ -n "\${__orca_codex_binary:-}" && -x "\${__orca_codex_binary}" ]]; then
# Why the function reserved word: it suppresses alias expansion of the name,
# which otherwise rewrites this header at parse time and aborts the whole file.
function codex {