On Friday, May 12, 2017 at 12:30:38 AM UTC-4, pjfarley3 wrote:
> I am testing some awk scripts with "gawk --lint --posix ..." to be transported to a system with a posix awk. For one of my scripts I get these warnings:
>
> gawk: warning: statement may have no effect
> gawk: warning: function `function1' defined but never called directly
> gawk: warning: function `function2' defined but never called directly
> gawk: warning: function `function3' defined but never called directly
> gawk: warning: function `function4' defined but never called directly
>
This is mysterious. I cannot duplicate the problem on Linux:
bash-4.2$ cat /tmp/test.awk
BEGIN {
print "hello"
5*2
}
function f1(x) {
print x
}
{
print
}
bash-4.2$ cat /tmp/test2.awk
function f2(x) {
print x
}
bash-4.2$ ./gawk --version | head -1
GNU Awk 4.1.4, API: 1.1 (GNU MPFR 3.1.1, GNU MP 6.0.0)
bash-4.2$ ./gawk --posix --lint -f /tmp/test.awk /tmp/test2.awk /dev/null > /dev/null
gawk: /tmp/test.awk:3: warning: statement may have no effect
gawk: warning: function `f1' defined but never called directly
There is only one place in the code where 'statement may have no effect' is issued, it it clearly includes the line number in the message. I am at a loss.
Regards,
Andy