diff --git a/libexec/goenv-commands b/libexec/goenv-commands index ca873693..404914c5 100755 --- a/libexec/goenv-commands +++ b/libexec/goenv-commands @@ -20,8 +20,6 @@ elif [ "$1" = "--no-sh" ]; then shift fi -IFS=: paths=($PATH) - shopt -s nullglob { @@ -35,21 +33,19 @@ shopt -s nullglob goenv-versions --bare fi - for path in "${paths[@]}"; do - for command in "${path}/goenv-"*; do - [ -x "$command" ] || continue - command="${command##*/goenv-}" - if [ -n "$sh" ]; then - if [ ${command:0:3} == "sh-" ]; then - echo "${command##sh-}" - fi - elif [ -n "$nosh" ]; then - if [ ${command:0:3} != "sh-" ]; then - echo "${command##sh-}" - fi - else + for command in $(compgen -c goenv-); do + [ -x "$(command -v "$command")" ] || continue + command="${command##goenv-}" + if [ -n "$sh" ]; then + if [[ ${command:0:3} == "sh-" ]]; then + echo "${command##sh-}" + fi + elif [ -n "$nosh" ]; then + if [[ ${command:0:3} != "sh-" ]]; then echo "${command##sh-}" fi - done + else + echo "${command##sh-}" + fi done } | sort | uniq | grep -v -E '^(echo|--version|realpath\.dylib)$'