2019-01-19 19:00:34 -07:00
|
|
|
shim_exec_command() {
|
2019-01-20 13:02:22 -07:00
|
|
|
local shim_name
|
|
|
|
shim_name=$(basename "$1")
|
|
|
|
local shim_args=("${@:2}")
|
2019-01-19 19:00:34 -07:00
|
|
|
|
2019-01-20 01:13:20 -07:00
|
|
|
if [ -z "$shim_name" ]; then
|
|
|
|
echo "usage: asdf exec <command>"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2019-01-20 13:02:22 -07:00
|
|
|
exec_shim() {
|
|
|
|
local plugin_name="$1"
|
|
|
|
local version="$2"
|
|
|
|
local executable_path="$3"
|
2019-01-19 19:00:34 -07:00
|
|
|
|
2019-01-20 13:02:22 -07:00
|
|
|
if [ ! -x "$executable_path" ]; then
|
|
|
|
echo "No ${shim_name} executable found for ${plugin_name} ${version}" >&2
|
|
|
|
exit 2
|
2019-01-19 19:00:34 -07:00
|
|
|
fi
|
|
|
|
|
2019-01-20 13:02:22 -07:00
|
|
|
asdf_run_hook "pre_${plugin_name}_${shim_name}" "${shim_args[@]}"
|
2019-01-19 19:00:34 -07:00
|
|
|
pre_status=$?
|
2019-03-26 10:36:08 -07:00
|
|
|
if [ "$pre_status" -ne 0 ]; then
|
|
|
|
return "$pre_status"
|
2019-01-19 19:00:34 -07:00
|
|
|
fi
|
2019-03-26 10:36:08 -07:00
|
|
|
exec "$executable_path" "${shim_args[@]}"
|
2019-01-20 13:02:22 -07:00
|
|
|
}
|
2019-01-19 19:00:34 -07:00
|
|
|
|
2019-01-20 13:02:22 -07:00
|
|
|
with_shim_executable "$shim_name" exec_shim || exit $?
|
2019-01-19 19:00:34 -07:00
|
|
|
}
|