helpers/go: add double quotes to trigger syntax errors when bugs occur instead of silently behaving incorrectly.

This commit is contained in:
Salamandar 2024-06-03 12:02:17 +02:00
parent e6b676df5b
commit 841f6500b5

View file

@ -154,12 +154,12 @@ ynh_install_go () {
test -x /usr/bin/go_goenv && mv /usr/bin/go_goenv /usr/bin/go test -x /usr/bin/go_goenv && mv /usr/bin/go_goenv /usr/bin/go
# Install the requested version of Go # Install the requested version of Go
local final_go_version=$(goenv latest --print $go_version) local final_go_version=$(goenv latest --print "$go_version")
ynh_print_info --message="Installation of Go-$final_go_version" ynh_print_info --message="Installation of Go-$final_go_version"
goenv install --skip-existing $final_go_version goenv install --skip-existing "$final_go_version"
# Store go_version into the config of this app # Store go_version into the config of this app
ynh_app_setting_set --app=$YNH_APP_INSTANCE_NAME --key=go_version --value=$final_go_version ynh_app_setting_set --app="$YNH_APP_INSTANCE_NAME" --key="go_version" --value="$final_go_version"
# Cleanup Go versions # Cleanup Go versions
ynh_cleanup_go ynh_cleanup_go
@ -181,7 +181,7 @@ eval \"\$(goenv init -)\"
# #
# usage: ynh_remove_go # usage: ynh_remove_go
ynh_remove_go () { ynh_remove_go () {
local go_version=$(ynh_app_setting_get --app=$YNH_APP_INSTANCE_NAME --key=go_version) local go_version=$(ynh_app_setting_get --app="$YNH_APP_INSTANCE_NAME" --key="go_version")
# Load goenv path in PATH # Load goenv path in PATH
local CLEAR_PATH="$goenv_install_dir/bin:$PATH" local CLEAR_PATH="$goenv_install_dir/bin:$PATH"
@ -190,7 +190,7 @@ ynh_remove_go () {
PATH=$(echo $CLEAR_PATH | sed 's@/usr/local/bin:@@') PATH=$(echo $CLEAR_PATH | sed 's@/usr/local/bin:@@')
# Remove the line for this app # Remove the line for this app
ynh_app_setting_delete --app=$YNH_APP_INSTANCE_NAME --key=go_version ynh_app_setting_delete --app="$YNH_APP_INSTANCE_NAME" --key="go_version"
# Cleanup Go versions # Cleanup Go versions
ynh_cleanup_go ynh_cleanup_go
@ -224,7 +224,7 @@ ynh_cleanup_go () {
if ! `echo ${required_go_versions} | grep "${installed_go_version}" 1>/dev/null 2>&1` if ! `echo ${required_go_versions} | grep "${installed_go_version}" 1>/dev/null 2>&1`
then then
ynh_print_info --message="Removing of Go-$installed_go_version" ynh_print_info --message="Removing of Go-$installed_go_version"
$goenv_install_dir/bin/goenv uninstall --force $installed_go_version $goenv_install_dir/bin/goenv uninstall --force "$installed_go_version"
fi fi
done done