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 <[email protected]>
---
 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 "${optdepen...@]}"; do
-               local pkg=${optdepend%%:*}
-               if [[ ! $pkg =~ ^[[:alnum:]\>\<\=\.\+\_\-]*$ ]]; then
-                       error "$(gettext "Invalid syntax for optdepend : 
'%s'")" "$optdepend"
+       local regex='^[[:alnum:]><=.+_-]+$'
+       for i in "${optdepen...@]}"; 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


Reply via email to