goawk
goawk copied to clipboard
Redirection to stdout and order
test.awk:
BEGIN {
STDERR = "/dev/stderr"
print("First send to stderr") > STDERR
print("Second send to stdout")
}
goawk -f test.awk produces:
Second send to stdout
First send to stderr
All other awk variants I use, produce:
First send to stderr
Second send to stdout
I observed this (only with goawk) while writing tests with expected output which includes both stdout and stderr messages. Using fflush() or fflush(STDERR) in the simple example above gives me the expected order but it didn't help in my actual tests (it is not possible to reproduce the problem here and there was some randomness involved). Now, I solved the problem by comparing stdout and stderr separately so all this is not a blocker for me but I am just reporting it in case you are not aware of this behaviour of goawk.