[pacman-dev] [PATCH] makepkg: trim trailing space from whitespace sensitive vars
Dan McGee
dpmcgee at gmail.com
Thu Nov 17 21:28:27 EST 2011
On Thu, Nov 17, 2011 at 1:09 PM, Dave Reisner <d at 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 at 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?
> 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