From 03b674c3a69758eb2a682bc2df94fbc308ac1f3b Mon Sep 17 00:00:00 2001
From: Sertonix <sertonix@posteo.net>
Date: Sun, 16 Feb 2025 12:52:46 +0100
Subject: [PATCH] abuild: simplify {replaces,provider}_priority validation with
 case

Also this way is much safer since it isn't using echo or shell expansion
---
 abuild.in | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/abuild.in b/abuild.in
index 2cdd4a29..a3fb6f21 100644
--- a/abuild.in
+++ b/abuild.in
@@ -212,15 +212,13 @@ default_validate() {
 	fi
 	is_function package || die "Missing package() function in APKBUILD"
 
-	if [ -n "$replaces_priority" ] \
-		&& ! echo $replaces_priority | grep -E -q '^[0-9]+$'; then
-		die "replaces_priority must be a number"
-	fi
+	case "$replaces_priority" in
+		*[!0-9]*) die "replaces_priority must be a number" ;;
+	esac
 
-	if [ -n "$provider_priority" ] \
-		&& ! echo $provider_priority | grep -E -q '^[0-9]+$'; then
-		die "provider_priority must be a number"
-	fi
+	case "$provider_priority" in
+		*[!0-9]*) die "provider_priority must be a number" ;;
+	esac
 
 	# check pkgname and subpkgnames
 	for i in "$pkgname" $subpackages; do
-- 
GitLab