2019-11-27 01:24:29 -07:00
|
|
|
# -*- sh -*-
|
|
|
|
|
2018-02-25 16:34:39 -07:00
|
|
|
which_command() {
|
2019-01-20 13:02:22 -07:00
|
|
|
local shim_name
|
|
|
|
shim_name=$(basename "$1")
|
2018-10-20 20:47:13 -07:00
|
|
|
|
2019-01-20 13:02:22 -07:00
|
|
|
if [ -z "$shim_name" ]; then
|
2022-12-23 02:53:22 -07:00
|
|
|
printf "usage: asdf which <command>\n"
|
2018-11-12 10:30:44 -07:00
|
|
|
exit 1
|
2017-03-15 20:57:07 -07:00
|
|
|
fi
|
2019-01-20 13:02:22 -07:00
|
|
|
|
|
|
|
print_exec() {
|
|
|
|
local plugin_name="$1"
|
|
|
|
local version="$2"
|
|
|
|
local executable_path="$3"
|
|
|
|
|
|
|
|
if [ ! -x "$executable_path" ]; then
|
2022-12-23 02:53:22 -07:00
|
|
|
printf "No %s executable found for %s %s\n" "$shim_name" "$plugin_name" "$version" >&2
|
2019-01-20 13:02:22 -07:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2022-12-23 02:53:22 -07:00
|
|
|
printf "%s\n" "$executable_path"
|
2019-01-20 13:02:22 -07:00
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
|
|
|
|
with_shim_executable "$shim_name" print_exec || exit 1
|
2018-11-28 17:31:31 -07:00
|
|
|
}
|
2019-11-27 01:24:29 -07:00
|
|
|
|
|
|
|
which_command "$@"
|