When calling Bytes from a pipe, it does not return an error when the Exec on the pipe returns a non-zero exit status.
// This test fails
func TestBytesFailOnCmdFail(t *testing.T) {
_, err := script.Exec("sh -c 'exit 1'").Bytes()
if err == nil {
t.Fatal("expected error")
}
}
In contrast, the String method does return an error in these situations. The difference between the two is that the final return expression in String returns *Pipe.Error() as the error return value vs nil in Bytes.
I think it would be clearer for the two methods to behave in a consistent way.