asdf/lib/commands/reshim.bash

26 lines
606 B
Bash
Raw Normal View History

remove_shim_for_version() {
local plugin_name=$1
local version=$2
local shim_name
shim_name=$(basename "$3")
2017-09-04 10:04:56 -07:00
local shim_path
shim_path="$(asdf_data_dir)/shims/$shim_name"
2017-09-04 10:04:56 -07:00
local count_installed
count_installed=$(list_installed_versions "$plugin_name" | wc -l)
2019-11-29 09:15:38 -07:00
if ! grep -x "# asdf-plugin: $plugin_name $version" "$shim_path" >/dev/null 2>&1; then
return 0
fi
sed -i.bak -e "/# asdf-plugin: $plugin_name $version"'$/d' "$shim_path"
rm "$shim_path".bak
2019-11-29 09:15:38 -07:00
if ! grep "# asdf-plugin:" "$shim_path" >/dev/null ||
[ "$count_installed" -eq 0 ]; then
rm "$shim_path"
fi
}