mirror of
https://github.com/rbenv/rbenv.git
synced 2025-01-01 14:45:03 +01:00
commit
e7fd07dd91
1 changed files with 7 additions and 9 deletions
|
@ -97,21 +97,19 @@ make_shims() {
|
||||||
local file shim
|
local file shim
|
||||||
for file; do
|
for file; do
|
||||||
shim="${file##*/}"
|
shim="${file##*/}"
|
||||||
register_shim "$shim"
|
registered_shims+=("$shim")
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
registered_shims=" "
|
|
||||||
|
|
||||||
# Registers the name of a shim to be generated.
|
# Registers the name of a shim to be generated.
|
||||||
register_shim() {
|
register_shim() {
|
||||||
registered_shims="${registered_shims}${1} "
|
registered_shims+=("$1")
|
||||||
}
|
}
|
||||||
|
|
||||||
# Install all the shims registered via `make_shims` or `register_shim` directly.
|
# Install all the shims registered via `make_shims` or `register_shim` directly.
|
||||||
install_registered_shims() {
|
install_registered_shims() {
|
||||||
local shim file
|
local shim file
|
||||||
for shim in $registered_shims; do
|
for shim in "${registered_shims[@]}"; do
|
||||||
file="${SHIM_PATH}/${shim}"
|
file="${SHIM_PATH}/${shim}"
|
||||||
[ -e "$file" ] || cp "$PROTOTYPE_SHIM_PATH" "$file"
|
[ -e "$file" ] || cp "$PROTOTYPE_SHIM_PATH" "$file"
|
||||||
done
|
done
|
||||||
|
@ -123,8 +121,9 @@ install_registered_shims() {
|
||||||
# removed.
|
# removed.
|
||||||
remove_stale_shims() {
|
remove_stale_shims() {
|
||||||
local shim
|
local shim
|
||||||
|
local known_shims=" ${registered_shims[*]} "
|
||||||
for shim in "$SHIM_PATH"/*; do
|
for shim in "$SHIM_PATH"/*; do
|
||||||
if [[ "$registered_shims" != *" ${shim##*/} "* ]]; then
|
if [[ "$known_shims" != *" ${shim##*/} "* ]]; then
|
||||||
rm -f "$shim"
|
rm -f "$shim"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
@ -136,9 +135,8 @@ shopt -s nullglob
|
||||||
# executables.
|
# executables.
|
||||||
create_prototype_shim
|
create_prototype_shim
|
||||||
remove_outdated_shims
|
remove_outdated_shims
|
||||||
# shellcheck disable=SC2046
|
# shellcheck disable=SC2207
|
||||||
make_shims $(list_executable_names | sort -u)
|
registered_shims=( $(list_executable_names | sort -u) )
|
||||||
|
|
||||||
|
|
||||||
# Allow plugins to register shims.
|
# Allow plugins to register shims.
|
||||||
OLDIFS="$IFS"
|
OLDIFS="$IFS"
|
||||||
|
|
Loading…
Reference in a new issue