bug-gnu-utils
[Top][All Lists]
Advanced

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

Re: gawk manpage "bug" (| operator).


From: Stepan Kasal
Subject: Re: gawk manpage "bug" (| operator).
Date: Wed, 23 Apr 2003 15:12:35 +0200
User-agent: Mutt/1.2.5.1i

Hello,
        thank you for the bug report.

On Sun, Apr 20, 2003, you mentioned the following problem:
> awk:   ( string string string | getline )

>     gawk interprets this as:
>         ( (string string string) | getline )

>     mawk interprets this as:
>         ( (string string) (string | getline) )

I can add that latest gawk, ie. version 3.1.2 interprets this
expression the same way as mawk.

The POSIX specification of the awk language,
http://www.opengroup.org/onlinepubs/007904975/utilities/awk.html ,
says that:
"The getline operator can form ambiguous constructs when
there are unparenthesized operators (including concatenate) to
the left of the '|' (to the beginning of the expression
containing getline). [...] The result of evaluating [...] is
unspecified, and conforming applications shall parenthesize
properly all such usages."

> Gawk 3.06 and Mawk 1.3.3 manpages are missing a listing
> for "|" in the "operator precedence" sections.

The POSIX doesn't include '|' in the precedence table either.  The info
documentation for latest gawk, 3.1.2, says that '|' has the same
precedence as relations (<=, >=, etc.).  (But the man page doesn't
mention this.)  But this is not fully correct, as is clear from the
example above.

The gawk manual also contains a warning that POSIX requires that such
expressions are properly parenthesized, see
http://www.gnu.org/manual/gawk-3.1.1/html_node/Getline-File.html
http://www.gnu.org/manual/gawk-3.1.1/html_node/Getline-Pipe.html
(The note that "It happens that gawk has it right" is no longer
true for 3.1.2.)

I hope this sufficiently explains the situation.

Regards,
        Stepan Kasal




reply via email to

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