From f55ce7812e7bf04a411ae5a42a940ca8f4c9b3d4 Mon Sep 17 00:00:00 2001 From: Bertrand Lorentz Date: Tue, 12 Aug 2025 09:41:33 +0200 Subject: [PATCH] Fix handling of missing required env variable Ensure the error message is displayed correctly when a required env variable is missing: add missing "echo" command and put the variable name in simple quotes instead of backticks so that it's not executed as a command. Fixes issue #1. --- 8.0/scripts/___mysqlexport.sh | 6 +++--- 8.0/scripts/___mysqlimport.sh | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/8.0/scripts/___mysqlexport.sh b/8.0/scripts/___mysqlexport.sh index 0efec20..20528dd 100755 --- a/8.0/scripts/___mysqlexport.sh +++ b/8.0/scripts/___mysqlexport.sh @@ -11,9 +11,9 @@ XDB_EXPORT_GZIP="$DB_EXPORT_GZIP" XDB_EXPORT= # Required env variables -if [[ -z "$DB_NAME" ]]; then "ERROR: `DB_NAME` env variable is required."; exit 1; fi -if [[ -z "$DB_USERNAME" ]]; then "ERROR: `DB_USERNAME` env variable is required."; exit 1; fi -if [[ -z "$DB_PASSWORD" ]]; then "ERROR: `DB_PASSWORD` env variable is required."; exit 1; fi +if [[ -z "$DB_NAME" ]]; then echo "ERROR: 'DB_NAME' env variable is required."; exit 1; fi +if [[ -z "$DB_USERNAME" ]]; then echo "ERROR: 'DB_USERNAME' env variable is required."; exit 1; fi +if [[ -z "$DB_PASSWORD" ]]; then echo "ERROR: 'DB_PASSWORD' env variable is required."; exit 1; fi # Optional env variables if [[ -z "$XDB_PROTO" ]]; then XDB_PROTO="tcp"; fi diff --git a/8.0/scripts/___mysqlimport.sh b/8.0/scripts/___mysqlimport.sh index d8690a8..d0cbf9e 100755 --- a/8.0/scripts/___mysqlimport.sh +++ b/8.0/scripts/___mysqlimport.sh @@ -13,10 +13,10 @@ XDB_IMPORT_GZIP="$DB_IMPORT_GZIP" XDB_IMPORT= # Required env variables -if [[ -z "$DB_NAME" ]]; then "ERROR: `DB_NAME` env variable is required."; exit 1; fi -if [[ -z "$DB_USERNAME" ]]; then "ERROR: `DB_USERNAME` env variable is required."; exit 1; fi -if [[ -z "$DB_PASSWORD" ]]; then "ERROR: `DB_PASSWORD` env variable is required."; exit 1; fi -if [[ -z "$DB_IMPORT_FILE_PATH" ]]; then "ERROR: `DB_IMPORT_FILE_PATH` env variable is required."; exit 1; fi +if [[ -z "$DB_NAME" ]]; then echo "ERROR: 'DB_NAME' env variable is required."; exit 1; fi +if [[ -z "$DB_USERNAME" ]]; then echo "ERROR: 'DB_USERNAME' env variable is required."; exit 1; fi +if [[ -z "$DB_PASSWORD" ]]; then echo "ERROR: 'DB_PASSWORD' env variable is required."; exit 1; fi +if [[ -z "$DB_IMPORT_FILE_PATH" ]]; then echo "ERROR: 'DB_IMPORT_FILE_PATH' env variable is required."; exit 1; fi # Optional env variables if [[ -z "$XDB_PROTO" ]]; then XDB_PROTO="tcp"; fi