summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustin Davis <jrcd83@gmail.com>2011-09-09 23:10:56 +0200
committerJustin Davis <jrcd83@gmail.com>2011-09-09 23:10:56 +0200
commitef15003ab4062b003fb94a343c3687677800f449 (patch)
treea6b6792c794b392991e9feaca7492b0540582598
parentd29fbd79ecb216a7552fbeb3960eacec42d9ff7d (diff)
downloadgenpkg-ef15003ab4062b003fb94a343c3687677800f449.tar.gz
genpkg-ef15003ab4062b003fb94a343c3687677800f449.tar.xz
Make bash quoting smarter. Only double-quote when a parameter is seen.
-rwxr-xr-xbin/templ/pbfields19
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)
+}