I am sorry, I may have not made myself clear earlier. This code is valid and actually works fine for me. I was just thinking that this particular example is very specific, where you manipulate with bash, so that it forwards stdout to stderr in it's second command(echo 1>&2 stderr). So in this case we actually are not getting an *exec.ExitError when we run the code, but forwarded stderr output by shell instead. If for instance we run any other command in bash, that will fail and output to stderr, the original example will break and exit with log.Fatal(err). So I was wondering if rewiring the example will be accepted by the go community.
Thank you all for your inputs. On Sunday, April 3, 2022 at 10:15:17 PM UTC+3 Brian Candler wrote: > On Sunday, 3 April 2022 at 16:49:30 UTC+1 mirha...@gmail.com wrote: > >> CombinedOutput example listed above will always print only stdout, but >> not combined stdout and stderr as intended to be shown in the example. > > > Works for me (macOS 10.12, go 1.18) > > If this doesn't work for you, it could be that the 'sh' on your system > isn't a POSIX-compatible shell. What happens if you change 'sh' to 'bash'? > > If it still doesn't work, can you say some more about the system you're > running on? Is it anything Windows-based (e.g. WSL or Cygwin?) > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/fc3123b6-da58-41c3-a640-76e69c5cd659n%40googlegroups.com.