mirror of
https://github.com/asdf-vm/asdf.git
synced 2024-11-15 01:28:17 -07:00
Don't allow unset variables in new Bash files
This commit is contained in:
parent
1ed64eb119
commit
1c8648dfe3
@ -2,7 +2,7 @@
|
||||
set -o nounset
|
||||
|
||||
shim_versions_command() {
|
||||
local shim_name=${1:-}
|
||||
local shim_name="${1:-}"
|
||||
shim_plugin_versions "$shim_name"
|
||||
}
|
||||
|
||||
|
@ -5,10 +5,10 @@ set -o nounset
|
||||
. "$(dirname "$ASDF_CMD_FILE")/reshim.bash"
|
||||
|
||||
uninstall_command() {
|
||||
local plugin_name=${1:-}
|
||||
local full_version=$2
|
||||
local plugin_name="${1:-}"
|
||||
local full_version="${2:-}"
|
||||
local plugin_path
|
||||
plugin_path=$(get_plugin_path "$plugin_name")
|
||||
plugin_path="$(get_plugin_path "$plugin_name")"
|
||||
|
||||
check_if_plugin_exists "$plugin_name"
|
||||
|
||||
@ -22,7 +22,7 @@ uninstall_command() {
|
||||
fi
|
||||
|
||||
local install_path
|
||||
install_path=$(get_install_path "$plugin_name" "$install_type" "$version")
|
||||
install_path="$(get_install_path "$plugin_name" "$install_type" "$version")"
|
||||
|
||||
if [ ! -d "$install_path" ]; then
|
||||
display_error "No such version"
|
||||
@ -47,8 +47,8 @@ uninstall_command() {
|
||||
}
|
||||
|
||||
remove_shims_for_version() {
|
||||
local plugin_name=${1:-}
|
||||
local full_version=$2
|
||||
local plugin_name="${1:-}"
|
||||
local full_version="${2:-}"
|
||||
for shim_path in $(plugin_shims "$plugin_name" "$full_version"); do
|
||||
remove_shim_for_version "$plugin_name" "$full_version" "$shim_path"
|
||||
done
|
||||
|
@ -2,7 +2,7 @@
|
||||
set -o nounset
|
||||
|
||||
update_command() {
|
||||
local update_to_head=${1:-}
|
||||
local update_to_head="${1:-}"
|
||||
|
||||
(
|
||||
cd "$(asdf_dir)" || exit 1
|
||||
@ -17,7 +17,7 @@ update_command() {
|
||||
}
|
||||
|
||||
do_update() {
|
||||
local update_to_head=${1:-}
|
||||
local update_to_head="${1:-}"
|
||||
|
||||
if [ "$update_to_head" = "--head" ]; then
|
||||
# Update to latest on the master branch
|
||||
|
@ -2,8 +2,8 @@
|
||||
set -o nounset
|
||||
|
||||
where_command() {
|
||||
local plugin_name=${1:-}
|
||||
local full_version=${2:-}
|
||||
local plugin_name="${1:-}"
|
||||
local full_version="${2:-}"
|
||||
check_if_plugin_exists "$plugin_name"
|
||||
|
||||
local version
|
||||
|
@ -1,4 +1,5 @@
|
||||
# -*- sh -*-
|
||||
|
||||
set -o nounset
|
||||
|
||||
which_command() {
|
||||
|
@ -27,8 +27,8 @@ remove_shim_for_version() {
|
||||
}
|
||||
|
||||
reshim_command() {
|
||||
local plugin_name=$1
|
||||
local full_version=$2
|
||||
local plugin_name="${1:-}"
|
||||
local full_version="${2:-}"
|
||||
|
||||
if [ -z "$plugin_name" ]; then
|
||||
local plugins_path
|
||||
@ -76,9 +76,9 @@ ensure_shims_dir() {
|
||||
}
|
||||
|
||||
write_shim_script() {
|
||||
local plugin_name=$1
|
||||
local version=$2
|
||||
local executable_path=$3
|
||||
local plugin_name="${1:-}"
|
||||
local version="${2:-}"
|
||||
local executable_path="${3:-}"
|
||||
|
||||
if ! is_executable "$executable_path"; then
|
||||
return 0
|
||||
@ -107,8 +107,8 @@ EOF
|
||||
}
|
||||
|
||||
generate_shim_for_executable() {
|
||||
local plugin_name=$1
|
||||
local executable=$2
|
||||
local plugin_name="${1:-}"
|
||||
local executable="${2:-}"
|
||||
|
||||
check_if_plugin_exists "$plugin_name"
|
||||
|
||||
@ -124,8 +124,8 @@ generate_shim_for_executable() {
|
||||
}
|
||||
|
||||
generate_shims_for_version() {
|
||||
local plugin_name=$1
|
||||
local full_version=$2
|
||||
local plugin_name="${1:-}"
|
||||
local full_version="${2:-}"
|
||||
local all_executable_paths
|
||||
IFS=$'\n' read -rd '' -a all_executable_paths <<<"$(plugin_executables "$plugin_name" "$full_version")"
|
||||
for executable_path in "${all_executable_paths[@]}"; do
|
||||
@ -134,8 +134,8 @@ generate_shims_for_version() {
|
||||
}
|
||||
|
||||
remove_obsolete_shims() {
|
||||
local plugin_name=$1
|
||||
local full_version=$2
|
||||
local plugin_name="${1:-}"
|
||||
local full_version="${2:-}"
|
||||
|
||||
local shims
|
||||
shims=$(plugin_shims "$plugin_name" "$full_version" | xargs -IX basename X | sort)
|
||||
@ -148,7 +148,7 @@ remove_obsolete_shims() {
|
||||
local formatted_exec_names
|
||||
|
||||
local temp_dir
|
||||
temp_dir=${TMPDIR:-/tmp}
|
||||
temp_dir="${TMPDIR:-/tmp}"
|
||||
|
||||
# comm only takes to files, so we write this data to temp files so we can
|
||||
# pass it to comm.
|
||||
|
@ -1,18 +1,18 @@
|
||||
handle_failure() {
|
||||
local install_path="$1"
|
||||
local install_path="${1:-}"
|
||||
rm -rf "$install_path"
|
||||
exit 1
|
||||
}
|
||||
|
||||
handle_cancel() {
|
||||
local install_path="$1"
|
||||
local install_path="${1:-}"
|
||||
printf "\\nreceived sigint, cleaning up"
|
||||
handle_failure "$install_path"
|
||||
}
|
||||
|
||||
install_command() {
|
||||
local plugin_name=$1
|
||||
local full_version=$2
|
||||
local plugin_name="${1:-}"
|
||||
local full_version="${2:-}"
|
||||
local extra_args="${*:3}"
|
||||
|
||||
if [ "$plugin_name" = "" ] && [ "$full_version" = "" ]; then
|
||||
@ -37,7 +37,7 @@ get_concurrency() {
|
||||
}
|
||||
|
||||
install_one_local_tool() {
|
||||
local plugin_name=$1
|
||||
local plugin_name="${1:-}"
|
||||
local search_path
|
||||
search_path=$(pwd)
|
||||
|
||||
@ -131,9 +131,9 @@ install_local_tool_versions() {
|
||||
}
|
||||
|
||||
install_tool_version() {
|
||||
local plugin_name=$1
|
||||
local full_version=$2
|
||||
local flags=$3
|
||||
local plugin_name="${1:-}"
|
||||
local full_version="${2:-}"
|
||||
local flags="${3:-}"
|
||||
local keep_download
|
||||
local plugin_path
|
||||
|
||||
|
@ -6,7 +6,7 @@ plugin_list_command() {
|
||||
local show_ref
|
||||
|
||||
while [ -n "$*" ]; do
|
||||
case "$1" in
|
||||
case "${1:-}" in
|
||||
"--urls")
|
||||
show_repo=true
|
||||
shift
|
||||
@ -109,8 +109,8 @@ plugin_update_command() {
|
||||
exit 1
|
||||
fi
|
||||
|
||||
local plugin_name="$1"
|
||||
local gitref="${2}"
|
||||
local plugin_name="${1:-}"
|
||||
local gitref="${2:-}"
|
||||
local plugins=
|
||||
|
||||
if [ "$plugin_name" = "--all" ]; then
|
||||
@ -130,10 +130,10 @@ plugin_update_command() {
|
||||
}
|
||||
|
||||
update_plugin() {
|
||||
local plugin_name=$1
|
||||
local plugin_path=$2
|
||||
plugin_remote_default_branch=$(git --git-dir "$plugin_path/.git" --work-tree "$plugin_path" ls-remote --symref origin HEAD | awk '{ sub(/refs\/heads\//, ""); print $2; exit }')
|
||||
local gitref=${3:-${plugin_remote_default_branch}}
|
||||
local plugin_name="${1:-}"
|
||||
local plugin_path="${2:-}"
|
||||
plugin_remote_default_branch="$(git --git-dir "$plugin_path/.git" --work-tree "$plugin_path" ls-remote --symref origin HEAD | awk '{ sub(/refs\/heads\//, ""); print $2; exit }')"
|
||||
local gitref="${3:-${plugin_remote_default_branch}}"
|
||||
logfile=$(mktemp)
|
||||
|
||||
local common_git_options=(--git-dir "$plugin_path/.git" --work-tree "$plugin_path")
|
||||
|
@ -1,6 +1,6 @@
|
||||
version_command() {
|
||||
local cmd=$1
|
||||
local plugin_name=$2
|
||||
local cmd="${1:-}"
|
||||
local plugin_name="${2:-}"
|
||||
|
||||
if [ "$#" -lt "3" ]; then
|
||||
if [ "$cmd" = "global" ]; then
|
||||
@ -65,17 +65,17 @@ version_command() {
|
||||
}
|
||||
|
||||
list_all_command() {
|
||||
local plugin_name=$1
|
||||
local query=$2
|
||||
local plugin_name="${1:-}"
|
||||
local query="${2:-}"
|
||||
local plugin_path
|
||||
local std_out_file
|
||||
local std_err_file
|
||||
local output
|
||||
plugin_path=$(get_plugin_path "$plugin_name")
|
||||
plugin_path="$(get_plugin_path "$plugin_name")"
|
||||
check_if_plugin_exists "$plugin_name"
|
||||
|
||||
local temp_dir
|
||||
temp_dir=${TMPDIR:-/tmp}
|
||||
temp_dir="${TMPDIR:-/tmp}"
|
||||
|
||||
# Capture return code to allow error handling
|
||||
std_out_file="$(mktemp "$temp_dir/asdf-command-list-all-${plugin_name}.stdout.XXXXXX")"
|
||||
@ -117,8 +117,8 @@ list_all_command() {
|
||||
latest_command() {
|
||||
DEFAULT_QUERY="[0-9]"
|
||||
|
||||
local plugin_name=$1
|
||||
local query=$2
|
||||
local plugin_name="${1:-}"
|
||||
local query="${2:-}"
|
||||
local plugin_path
|
||||
|
||||
if [ "$plugin_name" == "--all" ]; then
|
||||
|
Loading…
Reference in New Issue
Block a user