From e343bf7ffc7dad6e8df6cf7b4b31171544c0fcbb Mon Sep 17 00:00:00 2001 From: D-Jy Date: Mon, 15 Sep 2025 14:53:29 +0800 Subject: [PATCH] fix: prevent cd breakage in non-English locales by using locale-safe builtin detection and adding a builtin cd "$@" fallback https://github.com/moovweb/gvm/issues/457 --- scripts/env/cd | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/env/cd b/scripts/env/cd index ea1d1953..b7d1a4b0 100644 --- a/scripts/env/cd +++ b/scripts/env/cd @@ -18,8 +18,8 @@ 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)" == "cd is a shell builtin" ]]; then - eval "$(echo "__gvm_oldcd() { builtin cd \$*; return \$?; }")" +elif [[ "$(builtin type -t cd 2>/dev/null)" == builtin ]]; then + eval "$(echo "__gvm_oldcd() { if [ \"\$#\" -eq 0 ]; then builtin cd; return \$?; else builtin cd \"\$@\"; return \$?; fi }")" fi # Path cleanup @@ -46,7 +46,9 @@ export PATH="$(__gvm_munge_path)" cd() { # @FIXME: gvm_oldcd is broken on re-sourcing .bashrc! if __gvm_is_function __gvm_oldcd; then - __gvm_oldcd $* + __gvm_oldcd "$@" || return $? + else + builtin cd "$@" || return $? fi local dot_go_version dot_go_pkgset rslt