2017-07-26 13:00:55 -07:00
|
|
|
remove_shim_for_version() {
|
|
|
|
local plugin_name=$1
|
2019-01-19 03:12:52 -07:00
|
|
|
local version=$2
|
|
|
|
local shim_name
|
|
|
|
|
|
|
|
shim_name=$(basename "$3")
|
|
|
|
|
2017-09-04 10:04:56 -07:00
|
|
|
local shim_path
|
2019-01-19 03:12:52 -07:00
|
|
|
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)
|
2017-07-26 13:00:55 -07:00
|
|
|
|
2019-11-29 09:15:38 -07:00
|
|
|
if ! grep -x "# asdf-plugin: $plugin_name $version" "$shim_path" >/dev/null 2>&1; then
|
2017-07-26 13:00:55 -07:00
|
|
|
return 0
|
2015-05-17 10:44:16 -07:00
|
|
|
fi
|
|
|
|
|
2019-05-17 11:21:52 -07:00
|
|
|
sed -i.bak -e "/# asdf-plugin: $plugin_name $version"'$/d' "$shim_path"
|
2017-10-27 07:27:27 -07:00
|
|
|
rm "$shim_path".bak
|
2017-07-26 13:00:55 -07:00
|
|
|
|
2019-11-29 09:15:38 -07:00
|
|
|
if ! grep "# asdf-plugin:" "$shim_path" >/dev/null ||
|
|
|
|
[ "$count_installed" -eq 0 ]; then
|
2017-07-26 13:00:55 -07:00
|
|
|
rm "$shim_path"
|
|
|
|
fi
|
|
|
|
}
|