Skip to contentSkip to conversation

stable-2.02 - tests: fix unbound variable

PATCH Zdenek Kabelac 1 participant 1 message Oct 16, 2020

lore
Share & tools
lore
#0 lore raw
Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=d1db024e169c3c6af08477524e8048d54b678714
Commit:        d1db024e169c3c6af08477524e8048d54b678714
Parent:        6b3d0166ee2057ddaac3e73955e07acb1204be42
Author:        Marian Csontos <[email protected]>
AuthorDate:    Tue Jul 23 15:36:13 2019 +0200
Committer:     Zdenek Kabelac <[email protected]>
CommitterDate: Fri Oct 16 18:09:55 2020 +0200

tests: fix unbound variable

Test aux kernel_at_least 5 1 fails even for newer kernel with $3: unbound variable when using set -u.

---
 test/lib/aux.sh | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
test/lib/aux.sh +3 -3
index a84d41189..7235e69b8 100644
@@ -1548,17 +1548,17 @@ version_at_least() {
 	IFS=".-" read -r major minor revision <<< "$1"
 	shift
 
-	test -z "$1" && return 0
+	test -n "${1:-}" || return 0
 	test -n "$major" || return 1
 	test "$major" -gt "$1" && return 0
 	test "$major" -eq "$1" || return 1
 
-	test -z "$2" && return 0
+	test -n "${2:-}" || return 0
 	test -n "$minor" || return 1
 	test "$minor" -gt "$2" && return 0
 	test "$minor" -eq "$2" || return 1
 
-	test -z "$3" && return 0
+	test -n "${3:-}" || return 0
 	test "$revision" -ge "$3" 2>/dev/null || return 1
 }
 #