bug-gawk
[Top][All Lists]
Advanced

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

Re: [bug-gawk] BEGINFILE/ENDFILE bug?


From: Ed Morton
Subject: Re: [bug-gawk] BEGINFILE/ENDFILE bug?
Date: Sun, 18 May 2014 09:30:01 -0500
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0

Fair enough, thanks for the explanation.

    Ed.

On 5/18/2014 9:14 AM, Andrew J. Schorr wrote:
Hi Ed,

On Sun, May 18, 2014 at 08:15:46AM -0500, Ed Morton wrote:
wrt the error messages below - is there a difference between
"invalid" (as reported for ENDFILE) and "undefined" (as reported for
END)? If not maybe you could just use one or the other terms for
both?
In practice, there is a difference.  The "invalid" use of getline
inside BEGINFILE/ENDFILE causes the program to terminate with an
error.  But in an END rule, it merely triggers a warning message
if --lint is enabled.  This is how the patched version behaves:

bash-4.2$ ./gawk 'ENDFILE {getline; print}' /dev/null
gawk: cmd. line:1: error: non-redirected `getline' invalid inside `ENDFILE' rule
bash-4.2$ ./gawk 'END {getline; print}' /dev/null

bash-4.2$ ./gawk --lint 'END {getline; print}' /dev/null
gawk: cmd. line:1: warning: non-redirected `getline' undefined inside END action
gawk: cmd. line:1: warning: plain `print' in BEGIN or END rule should probably be `print 
""'
gawk: cmd. line:1: warning: reference to uninitialized field `$0'

bash-4.2$

So I think the current messages match the current behavior.  I am not
sure why a non-redirected getline inside an END rule does not terminate
the program.  Perhaps that behavior is required by the POSIX standard.
But as long as the 2 cases behave differently, I think they should probably
have different messages.

Regards,
Andy





reply via email to

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