[pacman-dev] [PATCH] makepkg: trim trailing space from whitespace sensitive vars

Dave Reisner d at falconindy.com
Thu Nov 17 14:09:32 EST 2011


Declarations such as:

pkgver=2.11    # foo

will work, but trimming off the comment (without trimming the trailing
whitespace) will result in an incorrect validation error. Bash automatically
trims this trailing whitespace and does the right thing under the covers,
so we should honor this as well.

NB: We don't need to worry about leading whitespace because it will cause a
syntax error (when unquoted), or fail validation (when quoted).

Signed-off-by: Dave Reisner <dreisner at archlinux.org>
---
Too late to squeeze this into maint?

 scripts/makepkg.sh.in |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index 085fbb9..39ce017 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -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
-- 
1.7.7.3



More information about the pacman-dev mailing list