makepkg: trim trailing space from whitespace sensitive vars

This applies to pkgver, pkgrel, and epoch and ensures that any trailing
whitespace outside of the context of the variable declaration itself is
properly trimmed. The Bash parser will ignore this, and so should we.

We don't need to worry about leading space because it would force a
syntax error, or fail validation.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Dave Reisner 2011-11-18 08:35:21 -05:00 committed by Dan McGee
parent c79c068fe9
commit b8ef22312b
1 changed files with 3 additions and 3 deletions

View File

@ -1441,7 +1441,7 @@ check_sanity() {
awk -F'=' '$1 ~ /^[[:space:]]*pkgver$/' "$BUILDFILE" | sed "s/[[:space:]]*#.*//" |
while IFS='=' read -r _ i; do
eval i=\"$(sed 's/^\(['\''"]\)\(.*\)\1$/\2/' <<< "$i")\"
eval i=\"$(sed 's/^\(['\''"]\)\(.*\)\1$/\2/' <<< "${i%%+([[:space:]])}")\"
if [[ $i = *[[:space:]:-]* ]]; then
error "$(gettext "%s is not allowed to contain colons, hyphens or whitespace.")" "pkgver"
return 1
@ -1450,7 +1450,7 @@ check_sanity() {
awk -F'=' '$1 ~ /^[[:space:]]*pkgrel$/' "$BUILDFILE" | sed "s/[[:space:]]*#.*//" |
while IFS='=' read -r _ i; do
eval i=\"$(sed 's/^\(['\''"]\)\(.*\)\1$/\2/' <<< "$i")\"
eval i=\"$(sed 's/^\(['\''"]\)\(.*\)\1$/\2/' <<< "${i%%+([[:space:]])}")\"
if [[ $i = *[[:space:]-]* ]]; then
error "$(gettext "%s is not allowed to contain hyphens or whitespace.")" "pkgrel"
return 1
@ -1459,7 +1459,7 @@ check_sanity() {
awk -F'=' '$1 ~ /^[[:space:]]*epoch$/' "$BUILDFILE" |
while IFS='=' read -r _ i; do
eval i=\"$(sed 's/^\(['\''"]\)\(.*\)\1$/\2/' <<< "$i")\"
eval i=\"$(sed 's/^\(['\''"]\)\(.*\)\1$/\2/' <<< "${i%%+([[:space:]])}")\"
if [[ $i != *([[:digit:]]) ]]; then
error "$(gettext "%s must be an integer.")" "epoch"
return 1