From 8cda612570d801654b81e38ca895bda784939edf Mon Sep 17 00:00:00 2001 From: huanglin Date: Wed, 24 Dec 2025 21:07:23 +0800 Subject: [PATCH] Handle aliased 'cd' in environment setup Update scripts/env/cd to support environments where cd is aliased (e.g., oh-my-bash). The alias is now captured into __gvm_oldcd and the alias is removed to allow GVM's cd function to take precedence while still preserving original behavior. --- scripts/env/cd | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/env/cd b/scripts/env/cd index ea1d1953..910f76ff 100644 --- a/scripts/env/cd +++ b/scripts/env/cd @@ -18,6 +18,9 @@ fi if __gvm_is_function cd; then eval "$(echo "__gvm_oldcd()"; declare -f cd | sed '1 s/{/\'$'\n''{/' | tail -n +2)" +elif [[ "$(builtin type cd)" == *"aliased to"* ]]; then + eval "__gvm_oldcd() { $(alias cd | sed "s/^alias cd=['\"]//; s/['\"]$//") \"\$@\"; }" + unalias cd elif [[ "$(builtin type cd)" == "cd is a shell builtin" ]]; then eval "$(echo "__gvm_oldcd() { builtin cd \$*; return \$?; }")" fi @@ -47,6 +50,8 @@ cd() { # @FIXME: gvm_oldcd is broken on re-sourcing .bashrc! if __gvm_is_function __gvm_oldcd; then __gvm_oldcd $* + else + builtin cd "$@" fi local dot_go_version dot_go_pkgset rslt