]> git.proxmox.com Git - pve-eslint.git/commitdiff
d/scripts/prepare-changes: make argument check more robust
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 15 Sep 2022 09:45:44 +0000 (11:45 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 15 Sep 2022 09:46:30 +0000 (11:46 +0200)
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>
debian/scripts/prepare-changes.sh

index b22404e3514341ddaa6991f55a72c0592f56a37e..f523b61d98dce99dcd473c1bcb762890eda4d332 100755 (executable)
@@ -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