On Thu, Nov 17, 2011 at 08:28:27PM -0600, Dan McGee wrote:
On Thu, Nov 17, 2011 at 1:09 PM, Dave Reisner <d@falconindy.com> wrote:
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@archlinux.org> --- Too late to squeeze this into maint? Nope, no string changes. Normally a test and signoff from Allan would go a long way to boost my confidence in last-minute changes, but he is gone, right? Anyone else want to give this patch a spin with PKGBUILDs testing the above cases?
Just gave it a try and tested it with a couple of PKGBUILDs in the Arch repositories, as well as test cases for the above-mentioned issue. The only thing I would change is the commit message: This only fixes cases of trailing whitespace if there is *no* comment (whitespace followed by a comment is already trimmed by `sed "s/[[:space:]]*#.*//"`). Apart from that: Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
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