[pacman-dev] [PATCH] makepkg: trim trailing space from whitespace sensitive vars
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
On Thu, Nov 17, 2011 at 1:09 PM, Dave Reisner
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
--- 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?
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
On Thu, Nov 17, 2011 at 08:28:27PM -0600, Dan McGee wrote:
On Thu, Nov 17, 2011 at 1:09 PM, Dave Reisner
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
--- 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
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
On 18/11/11 12:28, Dan McGee wrote:
On Thu, Nov 17, 2011 at 1:09 PM, Dave Reisner
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
--- 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?
Fix epoch too and I will give this a signoff... Allan
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
On 18/11/11 23:35, Dave Reisner wrote:
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
Signed-off-by: Allan
participants (4)
-
Allan McRae
-
Dan McGee
-
Dave Reisner
-
Lukas Fleischer