bug-gawk
[Top][All Lists]
Advanced

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

Re: [bug-gawk] Unstated differences between gawk and POSIX


From: arnold
Subject: Re: [bug-gawk] Unstated differences between gawk and POSIX
Date: Sun, 05 Aug 2018 01:53:19 -0600
User-agent: Heirloom mailx 12.4 7/29/08

Hi Ed.

I saw your earlier note also but have not had time to read the comp.lang.awk
thred in detail.

Ed Morton <address@hidden> wrote:

> OK, so apparently gawk really doesn't behave per the POSIX standard when 
> comparing numeric-string to numeric-string:
>
> In the Expressions In Awk 
> <http://pubs.opengroup.org/onlinepubs/9699919799/utilities/awk.html#tag_20_06_13_02>
>  
> section POSIX says:
>
>     Comparisons (with the '<', "<=", "!=", "==", '>', and ">=" operators) 
> shall
>     be made numerically if both operands are numeric, if one is numeric and 
> the
>     other has a string value that is a numeric string, or if one is numeric 
> and
>     the other has the uninitialized value. Otherwise, operands shall be
>     converted to strings as required and a string comparison shall be made

The text in POSIX is bogus. The intent and prior art are that as soon as one
operand is a numeric string then a numeric comparison is done. Otherwise
something as basic as

        echo 5.0 10.0 | awk '{ print ($1 < $2) }'

would print 0.

You might want to file an interpretation request with the Open Group.

I see no reason to:

- get excited
- change gawk's behavior
- issue any warnings
- or update any documentation (except maybe POSIX.STD)

Thanks,

Arnold



reply via email to

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