asdf/lib/commands/command-which.bash
Edwin Kofler 3492043241
fix: lint errors from scripts/checkstyle.py (#1385)
Co-authored-by: James Hegedus <jthegedus@hey.com>
2022-12-23 20:53:22 +11:00

30 lines
557 B
Bash

# -*- sh -*-
which_command() {
local shim_name
shim_name=$(basename "$1")
if [ -z "$shim_name" ]; then
printf "usage: asdf which <command>\n"
exit 1
fi
print_exec() {
local plugin_name="$1"
local version="$2"
local executable_path="$3"
if [ ! -x "$executable_path" ]; then
printf "No %s executable found for %s %s\n" "$shim_name" "$plugin_name" "$version" >&2
exit 1
fi
printf "%s\n" "$executable_path"
exit 0
}
with_shim_executable "$shim_name" print_exec || exit 1
}
which_command "$@"