summaryrefslogtreecommitdiff
path: root/scripts/readproperties.awk
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@typesafe.com>2015-02-02 22:59:15 -0800
committerAdriaan Moors <adriaan.moors@typesafe.com>2015-02-03 11:39:03 -0800
commit706d68f863ebffb0f63811afe0835c5f975ba225 (patch)
tree6c9a03ef34559511e08dec1d9098c2202ae48c13 /scripts/readproperties.awk
parent3115f885ff269b15eed307e5966bf2aec03904ab (diff)
downloadscala-706d68f863ebffb0f63811afe0835c5f975ba225.tar.gz
scala-706d68f863ebffb0f63811afe0835c5f975ba225.tar.bz2
scala-706d68f863ebffb0f63811afe0835c5f975ba225.zip
New CI validation scripts
Currently not validating the IDE, pending fix for https://github.com/scala-ide/uber-build/issues/48. The new infrastructure is documented over at: - https://github.com/scala/scabot - https://github.com/scala/scala-jenkins-infra - [jenkins jobs definitions](https://github.com/scala/scala-jenkins-infra/tree/master/templates/default/jobs/validate)
Diffstat (limited to 'scripts/readproperties.awk')
-rw-r--r--scripts/readproperties.awk39
1 files changed, 39 insertions, 0 deletions
diff --git a/scripts/readproperties.awk b/scripts/readproperties.awk
new file mode 100644
index 0000000000..96da94775b
--- /dev/null
+++ b/scripts/readproperties.awk
@@ -0,0 +1,39 @@
+# Adapted from http://stackoverflow.com/questions/1682442/reading-java-properties-file-from-bash/2318840#2318840
+BEGIN {
+ FS="=";
+ n="";
+ v="";
+ c=0; # Not a line continuation.
+}
+/^\#/ { # The line is a comment. Breaks line continuation.
+ c=0;
+ next;
+}
+/\\$/ && (c==0) && (NF>=2) { # Name value pair with a line continuation...
+ e=index($0,"=");
+ n=substr($0,1,e-1);
+ v=substr($0,e+1,length($0) - e - 1); # Trim off the backslash.
+ c=1; # Line continuation mode.
+ next;
+}
+/^[^\\]+\\$/ && (c==1) { # Line continuation. Accumulate the value.
+ v= "" v substr($0,1,length($0)-1);
+ next;
+}
+((c==1) || (NF>=2)) && !/^[^\\]+\\$/ { # End of line continuation, or a single line name/value pair
+ if (c==0) { # Single line name/value pair
+ e=index($0,"=");
+ n=substr($0,1,e-1);
+ v=substr($0,e+1,length($0) - e);
+ } else { # Line continuation mode - last line of the value.
+ c=0; # Turn off line continuation mode.
+ v= "" v $0;
+ }
+ # Make sure the name is a legal shell variable name
+ gsub(/[^A-Za-z0-9_]/,"_",n);
+ # Silently drop everything that might confuse bash.
+ gsub(/[\n\r\\\t'"\$!]/,"",v);
+ print "export " n "=\"" v "\" || echo \"Failed to set " n "\""; # don't make bash crap out when a property could not be parsed
+ n = "";
+ v = "";
+}