From 266842585b7d1b50882dc8f91bf2fe7b28a9959e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phan=20Sainl=C3=A9ger?= Date: Mon, 2 Feb 2026 17:55:02 +0100 Subject: [PATCH] [IMP] add argument validation with usage message Add proper argument validation at the start of upgrade.sh: - Check that exactly 4 arguments are provided - Display a helpful usage message with argument descriptions - Include a concrete example command This prevents cryptic errors when the script is called incorrectly and provides clear guidance on expected parameters. With set -u enabled, accessing unset positional parameters would cause an unclear error message. --- upgrade.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/upgrade.sh b/upgrade.sh index 7768f2e..b358643 100755 --- a/upgrade.sh +++ b/upgrade.sh @@ -1,6 +1,31 @@ #!/bin/bash set -euo pipefail +#################### +# USAGE & ARGUMENTS +#################### + +usage() { + cat <&2 +Usage: $0 + +Arguments: + origin_version Origin Odoo version number (e.g., 12 for version 12.0) + final_version Target Odoo version number (e.g., 16 for version 16.0) + db_name Name of the database to migrate + service_name Name of the origin Odoo service (docker compose service) + +Example: + $0 14 16 elabore_20241208 odoo14 +EOF + exit 1 +} + +if [[ $# -lt 4 ]]; then + echo "ERROR: Missing arguments. Expected 4, got $#." >&2 + usage +fi + #################### # GLOBAL VARIABLES # ####################