[pacman-dev] [PATCH 08/10] makepkg: do not ignore optdepends array with empty members

Andres P aepd87 at gmail.com
Fri Jun 25 19:16:43 EDT 2010


If optdepends was defined with empty members; optdepends=('' '' ''), the
behaviour would've been exit later rather than now, defeating the whole point
of the aptly named check_sanity.

Fixing this required changing the regex from <atom>* to <atom>+.

Also, move the regex into a var so that it doesn't need to be escaped and use
the standard i index to avoid having a destinct local assignment for every for
loop, which are numerous in this function.

Signed-off-by: Andres P <aepd87 at gmail.com>
---
 scripts/makepkg.sh.in |   11 +++++------
 1 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index 0958797..50cdae7 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -1213,15 +1213,14 @@ check_sanity() {
 		fi
 	fi
 
-	local optdepend
-	for optdepend in "${optdepends[@]}"; do
-		local pkg=${optdepend%%:*}
-		if [[ ! $pkg =~ ^[[:alnum:]\>\<\=\.\+\_\-]*$ ]]; then
-			error "$(gettext "Invalid syntax for optdepend : '%s'")" "$optdepend"
+	local regex='^[[:alnum:]><=.+_-]+$'
+	for i in "${optdepends[@]}"; do
+		i=${i%%:*}
+		if [[ ! $i =~ $regex ]]; then
+			error "$(gettext "Invalid syntax for optdepend: '%s'")" "$i"
 		fi
 	done
 
-	local i
 	for i in 'changelog' 'install'; do
 		local filelist=$(sed -n "s/^[[:space:]]*$i=//p" "$BUILDFILE") 
 		local file
-- 
1.7.1



More information about the pacman-dev mailing list