2018-02-25 16:34:39 -07:00
|
|
|
which_command() {
|
2018-11-12 10:30:44 -07:00
|
|
|
local command=$1 plugins_path not_found plugin_name full_version location
|
2018-10-20 20:47:13 -07:00
|
|
|
plugins_path=$(get_plugin_path)
|
|
|
|
|
|
|
|
if ls "$plugins_path" &> /dev/null; then
|
|
|
|
for plugin_path in "$plugins_path"/* ; do
|
|
|
|
plugin_name=$(basename "$plugin_path")
|
|
|
|
full_version=$(get_preset_version_for "$plugin_name")
|
2018-10-20 20:56:28 -07:00
|
|
|
# shellcheck disable=SC2162
|
2018-10-20 20:47:13 -07:00
|
|
|
IFS=' ' read -a versions <<< "$full_version"
|
|
|
|
for version in "${versions[@]}"; do
|
|
|
|
if [ -f "${plugin_path}/bin/exec-path" ]; then
|
|
|
|
cmd=$(basename "$executable_path")
|
2018-10-20 20:56:28 -07:00
|
|
|
install_path=$(find_install_path "$plugin_name" "$version")
|
2018-10-20 20:47:13 -07:00
|
|
|
executable_path="$("${plugin_path}/bin/exec-path" "$install_path" "$cmd" "$executable_path")"
|
|
|
|
fi
|
|
|
|
full_executable_path=$(get_executable_path "$plugin_name" "$version" "$executable_path")
|
2018-11-21 09:57:05 -07:00
|
|
|
location=$(find -L "$full_executable_path" -maxdepth 4 -name "$command" -type f -perm -u+x | sed -e 's|//|/|g')
|
2018-11-12 10:30:44 -07:00
|
|
|
if [ -n "$location" ]; then
|
2018-10-20 20:56:28 -07:00
|
|
|
echo "$location"
|
2018-10-20 20:47:13 -07:00
|
|
|
not_found=0
|
2018-11-12 10:30:44 -07:00
|
|
|
break 2
|
2018-10-20 20:47:13 -07:00
|
|
|
else
|
|
|
|
not_found=1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
done
|
2018-11-12 10:30:44 -07:00
|
|
|
fi
|
|
|
|
if [ $not_found -eq 1 ]; then
|
|
|
|
echo "No executable binary found for $command"
|
|
|
|
exit 1
|
2017-03-15 20:57:07 -07:00
|
|
|
fi
|
2018-10-20 20:47:13 -07:00
|
|
|
exit 0
|
|
|
|
}
|