mirror of
https://github.com/asdf-vm/asdf.git
synced 2024-11-15 01:28:17 -07:00
Add bash strict mode to lib/commands/install.sh
This commit is contained in:
parent
b1ec17870a
commit
547357a1d5
@ -1,3 +1,6 @@
|
|||||||
|
set -o nounset -o pipefail -o errexit
|
||||||
|
IFS=$'\t\n' # Stricter IFS settings
|
||||||
|
|
||||||
handle_failure() {
|
handle_failure() {
|
||||||
local install_path="$1"
|
local install_path="$1"
|
||||||
rm -rf "$install_path"
|
rm -rf "$install_path"
|
||||||
@ -11,8 +14,8 @@ handle_cancel() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
install_command() {
|
install_command() {
|
||||||
local plugin_name=$1
|
local plugin_name=${1:-}
|
||||||
local full_version=$2
|
local full_version=${2:-}
|
||||||
|
|
||||||
if [ "$plugin_name" = "" ] && [ "$full_version" = "" ]; then
|
if [ "$plugin_name" = "" ] && [ "$full_version" = "" ]; then
|
||||||
install_local_tool_versions
|
install_local_tool_versions
|
||||||
@ -41,7 +44,10 @@ install_local_tool_versions() {
|
|||||||
asdf_versions_path=$(find_tool_versions)
|
asdf_versions_path=$(find_tool_versions)
|
||||||
if [ -f "${asdf_versions_path}" ]; then
|
if [ -f "${asdf_versions_path}" ]; then
|
||||||
while IFS= read -r tool_line; do
|
while IFS= read -r tool_line; do
|
||||||
|
if [ -n "${tool_line:-}" ]; then
|
||||||
|
local tool_info
|
||||||
IFS=' ' read -r -a tool_info <<< "$tool_line"
|
IFS=' ' read -r -a tool_info <<< "$tool_line"
|
||||||
|
if [ -n "${tool_info:-}" ]; then
|
||||||
local tool_name
|
local tool_name
|
||||||
tool_name=$(echo "${tool_info[0]}" | xargs)
|
tool_name=$(echo "${tool_info[0]}" | xargs)
|
||||||
local tool_version
|
local tool_version
|
||||||
@ -50,6 +56,8 @@ install_local_tool_versions() {
|
|||||||
if ! [[ -z "$tool_name" || -z "$tool_version" ]]; then
|
if ! [[ -z "$tool_name" || -z "$tool_version" ]]; then
|
||||||
install_tool_version "$tool_name" "$tool_version"
|
install_tool_version "$tool_name" "$tool_version"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
done <<<"$(strip_tool_version_comments "$asdf_versions_path")"
|
done <<<"$(strip_tool_version_comments "$asdf_versions_path")"
|
||||||
else
|
else
|
||||||
echo "Either specify a tool & version in the command"
|
echo "Either specify a tool & version in the command"
|
||||||
|
@ -104,7 +104,7 @@ check_if_version_exists() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get_plugin_path() {
|
get_plugin_path() {
|
||||||
echo "$(asdf_data_dir)/plugins/$1"
|
echo "$(asdf_data_dir)/plugins/${1:-}"
|
||||||
}
|
}
|
||||||
|
|
||||||
display_error() {
|
display_error() {
|
||||||
@ -153,7 +153,7 @@ find_version() {
|
|||||||
local plugin_path
|
local plugin_path
|
||||||
plugin_path=$(get_plugin_path "$plugin_name")
|
plugin_path=$(get_plugin_path "$plugin_name")
|
||||||
local legacy_config
|
local legacy_config
|
||||||
legacy_config=$(get_asdf_config_value "legacy_version_file")
|
legacy_config=$(get_asdf_config_value "legacy_version_file" || true)
|
||||||
local legacy_list_filenames_script
|
local legacy_list_filenames_script
|
||||||
legacy_list_filenames_script="${plugin_path}/bin/list-legacy-filenames"
|
legacy_list_filenames_script="${plugin_path}/bin/list-legacy-filenames"
|
||||||
local legacy_filenames=""
|
local legacy_filenames=""
|
||||||
|
Loading…
Reference in New Issue
Block a user