From b26d1eb73ec98ac43032a5d076623f377d40d3bb Mon Sep 17 00:00:00 2001 From: selfhoster1312 Date: Sat, 24 Aug 2024 19:27:37 +0200 Subject: [PATCH] Run shellcheck to find bash common mistakes Complete command: shellcheck -e SC2154,SC1091,SC2034,SC2148 scripts/* --- scripts/_common.sh | 8 ++++---- scripts/change_url | 2 +- scripts/remove | 2 +- scripts/upgrade | 1 - 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index cfbfeec..344f5b1 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -38,12 +38,12 @@ rp_validate_assets_path() { try_files="try_files /dev/null @${app}--proxy;" else if [ ! -d "$assets_path" ]; then - ynh_die "Requested assets path "$assets_path" does not exist" 1 + ynh_die "Requested assets path ${assets_path} does not exist" 1 fi if [[ ! "$assets_path" =~ /$ ]]; then # Append missing trailing / - assets_path=""${assets_path}"/" + assets_path="${assets_path}/" fi assets_alias="alias $assets_path;" @@ -58,7 +58,7 @@ rp_handle_webroot() { path_slash="/" redirect_block="# Not needed for webroot" else - path_slash=""$path"/" - redirect_block="location = "$path" { return 302 "$path_slash"; }" + path_slash="$path"/ + redirect_block="location = ${path} { return 302 ${path_slash}; }" fi } diff --git a/scripts/change_url b/scripts/change_url index e73eb60..bc546d8 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -36,7 +36,7 @@ ynh_add_nginx_config if [[ "$old_domain" != "$new_domain" ]]; then new_nginx_conf_path=/etc/nginx/conf.d/$new_domain.d/$app.conf ynh_delete_file_checksum --file="$nginx_conf_path" - mv $nginx_conf_path $new_nginx_conf_path + mv "${nginx_conf_path}" "${new_nginx_conf_path}" ynh_store_file_checksum --file="$new_nginx_conf_path" fi diff --git a/scripts/remove b/scripts/remove index 984660f..46c23e1 100644 --- a/scripts/remove +++ b/scripts/remove @@ -14,7 +14,7 @@ source /usr/share/yunohost/helpers #================================================= # Remove configuration files -ynh_secure_remove /etc/nginx/conf.d/$domain.d/$app.conf +ynh_secure_remove "/etc/nginx/conf.d/${domain}.d/${app}.conf" #================================================= # END OF SCRIPT diff --git a/scripts/upgrade b/scripts/upgrade index 3030cdc..1ed1493 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,4 +1,3 @@ - #!/bin/bash #=================================================