jastrachan | 16 Feb 23:02 2004

process integration thoughts

I was taking a peek at the JDK and thought we could do some real clean 
process integration in groovy while sticking fairly close to the JDK.


Process process = Runtime.runtime.execute "java -version"

then we could add some helper methods to Process like...

// process the output of a script line by line
process.eachLine { line | ... }

// get all the output of a process in one string
text = process.getOutput()
value = process.exitValue()

So we could do things like

text = Runtime.runtime.execute( "some command ${foo} ${bar}").output

Unfortunately Runtime.runtime.execute() is a bit of a mouthful; maybe 
we can add a new static method to Runtime or System to make things 
simpler. Maybe we can use the `` as syntax sugar. e.g.

text = `some command ${foo} ${bar}`.output