[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Error in number comparison
From: |
Stepan Kasal |
Subject: |
Re: Error in number comparison |
Date: |
Thu, 23 May 2002 09:18:33 +0000 (UTC) |
User-agent: |
slrn/0.9.6.2 (Linux) |
On 23 May 2002 15:58:55 +0900, Miles Bader <address@hidden> wrote:
> I suspect gawk is treating them as octal numbers, using the `leading 0'
> convention of C/C++ (the gawk documentation talks about this, in the
> info node `(gawk)Nondecimal-numbers').
>
> You can disable this behavior by using the `--traditional' option, but
> this also turns off other gawk features; I'm not sure if there's anyway
> to disable just the interpretation of octal constants.
Hallo,
no, there is no other way to disable this behaviour of gawk, except
--traditional or --posix or setting environment variable POSIXLY_CORRECT.
Note that gawk doesn't treat numeric data on input treat as
non-decimal unless you explicitly ask for it (see the info node mentioned
above). Thus:
address@hidden gawk-3.1.1]$ echo x | ./gawk '010 == 10 {print "yes"}'
address@hidden gawk-3.1.1]$ echo 010 | ./gawk '$1 == 10 {print "yes"}'
yes
(I know that every dollar in Makefile hurts :-)
Perhaps the best variant looks like this:
$ echo x | POSIXLY_CORRECT= ./gawk '010 == 10 {print "yes"}'
yes
I.e. you set the variable at the top of the Makefile and make sure it's
exported.
Hope this helps,
Stepan Kasal