bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug-gawk] close/stdin bug


From: \"Chad Kline\"
Subject: [bug-gawk] close/stdin bug
Date: Tue, 4 Mar 2014 00:26:20 -0800 (PST)

Hi, I am coming from the awk expert irc channel - can't remember the details, 
but I was told this is worth reporting:
$ awk 'BEGIN { getline < "/dev/stdin"; close("/dev/stdin"); getline < 
"/dev/stdin"; print }'
Now, mawk 1.3.4 will request a line, perform the close function, and then 
request another line.
gawk 4.1.0 will request a line, and then shut down stdin permanently.

INHO, mawk has the correct behavior, as one would expect.  But gawk seems to 
open stdin once, and then if a close function is called with it, it cannot be 
opened again for the rest of the program.
There are several logical and practical reasons why I feel this is a bug:

1. stdin, for practical purposes, and common sense purposes, should function 
like any other file.  It should be able to "suffer" a close() function, and be 
read from again just like any other file.
2. this current behavior of gawk forces every single "open/read/close" 
file-type function to perform special checks on a file to make sure it's not 
the "evil stdin" that may shut down the entire program - and this is a needless 
and wasteful burden to impose on all open/read/close file functions.
3. this current behavior is not compatible with mawk, which seems to have the 
natural and correct behavior, and the wrong thing to do would be to expect mawk 
to "kill common sense, apparently correct, and practical usage".

For these reasons, I request that gawk be "fixed" to correct the aforementioned 
defects.  Thanks :)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]