In R 1.8.0 on Windows 2000 suppose that \a.awk contains:
BEGIN { print "on stdout"
print "on stderr" > "/dev/stderr"
}
which is a simple awk program that writes "on stdout" to stdout
and "on stderr" to stderr.
Then if I start up R I consistently get the following. That is,
the first pipe does not return anything. The second pipe returns
a weird character followed by BOTH the stdout and stderr output.
The third pipe does not return anything and then for subsequent
calls we are back to the weird character followed by BOTH the
stdout and stderr output.
I get similar behavior for other programs that use stdout and
stderr too -- not just gawk.
It looks like a bug to me but I thought I would ask before
submitting a report in case anyone has any insight into this.
> readLines(pipe("gawk -f \\a.awk"))
character(0)> readLines(pipe("gawk -f \\a.awk"))
[1] "on stdout" "on stderr" > readLines(pipe("gawk -f \\a.awk"))
character(0)> readLines(pipe("gawk -f \\a.awk"))
[1] "鴒n stdout" "on stderr" > readLines(pipe("gawk -f \\a.awk"))
[1] "Ton stdout" "on stderr" > readLines(pipe("gawk -f \\a.awk"))
[1] "on stdout" "on stderr"