[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Using getline into a variable from a coprocess sometimes overwrites RT
From: |
Nick Hobson |
Subject: |
Using getline into a variable from a coprocess sometimes overwrites RT |
Date: |
Fri, 2 Oct 2009 17:21:22 -0700 (PDT) |
Hi,
I think I've found a gawk bug. In some cases, using getline into a variable
from a coprocess clobbers RT. It doesn't touch $0 or NF. I have demonstrated
the problem in gawk 3.1.7 under Arch Linux.
The test program is:
BEGIN {RS = "u"}
RT == "u" {
printf callpgm("xargs file -b ", "imgs/auk.png")
}
function callpgm(ext, src, res) {
print src |& ext
close(ext, "to")
print "1", $0, NF, RT
ext |& getline res
print "2", $0, NF, RT
close(ext)
return res
}
The input data is:
bug
When run as echo 'bug' | bug.awk, the expected output is:
1 b 1 u
2 b 1 u
PNG image, 500 x 600, 8-bit colormap, non-interlaced
The actual output is:
1 b 1 u
2 b 1
PNG image, 500 x 600, 8-bit colormap, non-interlaced
The getline sets RT to the empty string. (The actual value RT is overwritten
with varies. If you change the above BEGIN block to RS = "[aeiou]", RT gets
overwritten with "i".)
Attached: bug.awk
Regards,
Nick Hobson
bug.awk
Description: Binary data
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Using getline into a variable from a coprocess sometimes overwrites RT,
Nick Hobson <=