d/scripts/prepare-changes: make argument check more robust

set -u aborts if we access any undefined variable, which $1 can be if
no argument got passed..

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2022-09-15 11:45:44 +02:00
parent 857347d600
commit 44f2865898

View File

@ -2,7 +2,8 @@
set -eu -o pipefail
if [[ $1 =~ ^-(h|-help)$ ]]; then
arg="${1:-}"
if [[ $arg =~ ^-(h|-help)$ ]]; then
echo "usage: $0 [<FROM-VERSION>]"
echo ""
echo "Filter out irrelevant entries (sponsors, chore, docs) from the upstream changelog."
@ -24,8 +25,8 @@ sed -i '/ ci: /Id' "$cfn"
sed -i '/ build: /Id' "$cfn"
sed -i '/ESLint Jenkins/Id' "$cfn"
if [[ $1 ]]; then
version="$1"
if [[ $arg ]]; then
version="$arg"
sed -i "/^$version -/Q" "$cfn"
sed -i '/^\+ /!d' "$cfn"
fi