Closed mbigras closed 7 years ago
If you want to prevent stdout and stderr logging ,you can set the sh logger. You can also access that logger and set its level higher (though note by default that logger is the app-wide logger).
You can then access the stderr using the block form:
sh "git clone" do |stdout,stderr|
# ...
end
The thinking behind the default behavior is that when you use sh
you generally aren't expecting stderr
, so if you get some, it gets output to the log. If git is producing non-error messages to stderr, that is git deviating from UNIX standard and methadone can't possibly know about that to squelch the error output (you'd have the same issue using bash).
Is there a way to tell
sh
not to output thestderr
of it's given command?git clone
is sending it's output tostderr
; however, oncesh
gets ahold of itfullstop
sends it tostdout
.The fix for me is to send the
stderr
ofgit clone
to/dev/null
but I'm not sure if this is ideal since I don't think it can be logged anymore once I do that, shown below:before sending git clone to
/dev/null
:after sending git clone to
dev/null
:Is there a better way to go about grabbing a command's stderr with
sh
?Edit:
Taking a look at Methadone::SH it looks like
sh
is logging the stderr output ofgit log
here:And it also seems like
warn
outputs tostdout
.In the case of full stop wouldn't we not want this output:
by going to stdout by default?