aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorJoseph Carter <[email protected]>2016-09-07 13:32:36 -0700
committerXECDesign <[email protected]>2016-09-08 06:32:36 +1000
commitabc3e45727d0ed1a7804ed68a8a1c1b096b8372c (patch)
tree5cd9e7f3cfc32301afe7826a7ef955c8d3c3507a /scripts
parentb9b8df3d113288765e893e181e6c3ea54cab5f43 (diff)
build.sh: Support comments in package files (#14)
* build.sh: Support comments in package files This patch allows the use of hash comments inside patch files. It's a little ugly, but it strips comments and collapses all whitespace down to single space characters between package names. It handles comments anywhere in a line, as well. Was unsure if \ continuation of the long sed line or the inclusion of a couple of lines of comments explaining what the sed expressions are doing would be appreciated, so didn't include them in this patch. * build.sh: whitespace fix * build.sh: Use sed script for packages files Broke the sed expressions out of build.sh and put them their own documented sed script. This greatly improves readability and avoids build.sh getting messier. Broke the substitution command into two separate subs. The first just deletes comments, and the second collapses all whitespace into a single space. This too is easier to read, and catches a couple of edge cases that would result it not all whitespace being collapsed. The result may still have (one) leading and/or trailing space, which is acceptable.
Diffstat (limited to 'scripts')
-rw-r--r--scripts/remove-comments.sed11
1 files changed, 11 insertions, 0 deletions
diff --git a/scripts/remove-comments.sed b/scripts/remove-comments.sed
new file mode 100644
index 0000000..2a6889f
--- /dev/null
+++ b/scripts/remove-comments.sed
@@ -0,0 +1,11 @@
+# Deletes comments and collapses whitespace in ##-packages files
+
+# Append (N)ext line to buffer
+# if (!)not ($)buffer is EOF, (b)ranch to (:)label loop
+:loop
+N
+$ !b loop
+
+# Buffer is "line1\nline2\n...lineN", del comments and collapse whitespace
+s/#[^\n]*//g
+s/[[:space:]]\{1,\}/ /g