I'm looking for a way to redirect output in a groovy script to stderr:
catch(Exception e) {
println "Want this to go to stderr"
}
Just off the top of my head couldn't you do a bit of self-wiring:
def printErr = System.err.&println printErr("AHHH")
but that is a bit manual
Groovy has access to the JRE:
System.err.println "goes to stderr"
Although there may be a more Groovy-fied way...
Another quite compact alternative is this:
System.err << "Want this to go to stderr"
Or you could add this at the top of your script
def err = System.err
...
err << "Want this to go to stderr"
which is what I'm now doing in my groovy shell scripts
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With