Use regexp matching to parse NAME=VALUE pairs given as command line arguments
authorJan Vrany <jan.vrany@fit.cvut.cz>
Sun, 22 May 2016 01:14:35 +0100
changeset 2 d5cd0cfb84d5
parent 1 fdbc4b7badf9
child 3 18c56730fabf
Use regexp matching to parse NAME=VALUE pairs given as command line arguments ...rather then using `split('=")`.
rakelib/support.rb
--- a/rakelib/support.rb	Sun May 22 01:13:00 2016 +0100
+++ b/rakelib/support.rb	Sun May 22 01:14:35 2016 +0100
@@ -1,16 +1,21 @@
+# Following hack is required to allow passing variable
+# values in `make` style, i.e., to allow for
+#
+#  rake PROJECT=stx:jv-branch compile
+#
+ARGV.each do | arg |
+  name_and_value = /^([A-Za-z_]+)\w*=(.*)/.match(arg)
+  if name_and_value
+     self.class.const_set(name_and_value[1], name_and_value[2])  
+  end
+end
+
 module Rake
 end
 
 module Rake::StX
 end
 
-ARGV.each do | arg |
-  if arg =~ /[A-Za-z_]\w*=[^=]*/
-    name_and_value = arg.split('=')
-    self.class.const_set(name_and_value[0], name_and_value[1])  
-  end
-end
-
 require 'rakelib/extensions.rb'
 require 'rakelib/rbspec.rb'
 require 'rakelib/vcs.rb'