diff options
author | Justin Davis <jrcd83@gmail.com> | 2011-09-09 23:10:56 +0200 |
---|---|---|
committer | Justin Davis <jrcd83@gmail.com> | 2011-09-09 23:10:56 +0200 |
commit | ef15003ab4062b003fb94a343c3687677800f449 (patch) | |
tree | a6b6792c794b392991e9feaca7492b0540582598 | |
parent | d29fbd79ecb216a7552fbeb3960eacec42d9ff7d (diff) | |
download | genpkg-ef15003ab4062b003fb94a343c3687677800f449.tar.gz genpkg-ef15003ab4062b003fb94a343c3687677800f449.tar.xz |
Make bash quoting smarter. Only double-quote when a parameter is seen.
-rwxr-xr-x | bin/templ/pbfields | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/bin/templ/pbfields b/bin/templ/pbfields index f0a2ff7..4bbfdfc 100755 --- a/bin/templ/pbfields +++ b/bin/templ/pbfields @@ -19,13 +19,7 @@ BEGIN { NF < 2 { next } -$1 ~ /depends$|conflicts|provides/ { - for (i=2; i<=NF; i++) $i = sprintf("'%s'", $i) -} - -$1 == "source" { - for (i=2; i<=NF; i++) $i = sprintf("\"%s\"", $i) -} +$1 ~ /depends$|conflicts|provides|source/ { quotevals() } $1 == "pkgdesc" { gsub(/[$"`]/, "\\\\&", $2) @@ -77,3 +71,14 @@ function wraparray (indent) return txt } + +function quotevals () +{ + for (i=2; i<=NF; i++) $i = bashquote($i) +} + +function bashquote (val) +{ + if (val ~ /\$/) return sprintf("\"%s\"", val) + return sprintf("'%s'", val) +} |