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