pyenv/libexec/rbenv-commands

50 lines
1.1 KiB
Plaintext
Raw Normal View History

#!/usr/bin/env bash
# Summary: List all available rbenv commands
# Usage: rbenv commands [--sh|--no-sh]
#
# List names of all rbenv commands, including 3rd-party ones found in the
# PATH or in rbenv plugins. With `--sh`, list only shell commands.
#
# This functionality is mainly meant for scripting. To see usage help for
# rbenv, run `rbenv help`.
set -e
[ -n "$RBENV_DEBUG" ] && set -x
2011-08-03 22:20:01 -05:00
2011-09-13 12:48:49 -05:00
# Provide rbenv completions
if [ "$1" = "--complete" ]; then
2011-09-13 13:12:04 -05:00
echo --sh
echo --no-sh
2011-09-13 12:48:49 -05:00
exit
fi
2011-08-23 11:34:03 -05:00
if [ "$1" = "--sh" ]; then
sh=1
shift
2011-09-13 12:48:49 -05:00
elif [ "$1" = "--no-sh" ]; then
2011-09-06 22:07:05 -05:00
nosh=1
shift
fi
IFS=: read -d '' -r -a paths <<<"$PATH" || true
2011-08-03 22:20:01 -05:00
shopt -s nullglob
{ for path in "${paths[@]}"; do
2011-08-03 22:20:01 -05:00
for command in "${path}/rbenv-"*; do
2011-08-23 11:34:03 -05:00
command="${command##*rbenv-}"
if [ -n "$sh" ]; then
2017-06-24 00:12:09 +02:00
if [ "${command:0:3}" = "sh-" ]; then
echo "${command##sh-}"
2011-08-23 11:34:03 -05:00
fi
2011-09-06 22:07:05 -05:00
elif [ -n "$nosh" ]; then
2017-06-24 00:12:09 +02:00
if [ "${command:0:3}" != "sh-" ]; then
echo "${command##sh-}"
2011-08-23 11:34:03 -05:00
fi
2011-09-06 22:07:05 -05:00
else
2017-06-24 00:12:09 +02:00
echo "${command##sh-}"
2011-08-23 11:34:03 -05:00
fi
2011-08-03 22:20:01 -05:00
done
done
} | sort | uniq