Skip to content

Commit

Permalink
dont use the user's paths. Instead use compgen (#429)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChronosMasterOfAllTime authored Dec 20, 2024
1 parent 02b26b1 commit 0528667
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions libexec/goenv-commands
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ elif [ "$1" = "--no-sh" ]; then
shift
fi

IFS=: paths=($PATH)

shopt -s nullglob

{
Expand All @@ -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)$'

0 comments on commit 0528667

Please # to comment.