diff --git a/bin/asdf b/bin/asdf index 4a15f61f..439fd181 100755 --- a/bin/asdf +++ b/bin/asdf @@ -1,5 +1,9 @@ #!/usr/bin/env bash + set -o pipefail +if [[ "${ASDF_DEBUG}" == "1" ]]; then + set -x +fi # shellcheck source=lib/utils.bash . "$(dirname "$(dirname "$0")")/lib/utils.bash" diff --git a/lib/functions/plugins.bash b/lib/functions/plugins.bash index 3b36ddd9..6f7a9435 100644 --- a/lib/functions/plugins.bash +++ b/lib/functions/plugins.bash @@ -76,7 +76,7 @@ plugin_add_command() { local plugin_path plugin_path=$(get_plugin_path "$plugin_name") - mkdir -p "$(asdf_data_dir)/plugins" + [ -d "$(asdf_data_dir)/plugins" ] || mkdir -p "$(asdf_data_dir)/plugins" if [ -d "$plugin_path" ]; then printf '%s\n' "Plugin named $plugin_name already added" diff --git a/lib/utils.bash b/lib/utils.bash index 8eae18fc..21978a92 100644 --- a/lib/utils.bash +++ b/lib/utils.bash @@ -62,7 +62,7 @@ get_install_path() { local install_dir install_dir="$(asdf_data_dir)/installs" - mkdir -p "${install_dir}/${plugin}" + [ -d "${install_dir}/${plugin}" ] || mkdir -p "${install_dir}/${plugin}" if [ "$install_type" = "version" ]; then printf "%s/%s/%s\n" "$install_dir" "$plugin" "$version" @@ -81,7 +81,7 @@ get_download_path() { local download_dir download_dir="$(asdf_data_dir)/downloads" - mkdir -p "${download_dir}/${plugin}" + [ -d "${download_dir}/${plugin}" ] || mkdir -p "${download_dir}/${plugin}" if [ "$install_type" = "version" ]; then printf "%s/%s/%s\n" "$download_dir" "$plugin" "$version" @@ -442,7 +442,7 @@ initialize_or_update_plugin_repository() { git -C "$repository_path" reset --hard origin/master fi - mkdir -p "$(asdf_data_dir)/tmp" + [ -d "$(asdf_data_dir)/tmp" ] || mkdir -p "$(asdf_data_dir)/tmp" touch "$(asdf_data_dir)/tmp/repo-updated" }