[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug-gawk] Is this a bug
From: |
Davide Brini |
Subject: |
Re: [bug-gawk] Is this a bug |
Date: |
Sat, 8 Mar 2014 15:15:43 +0100 |
On Sat, 08 Mar 2014 12:44:03 +0100, Seppo Lehtikangas <address@hidden>
wrote:
> Hi!
>
> I have been using some time to find annoying error in my awk-code.
>
> I had to strip almost the whole code to find the error because awk tells
> me that there is syntax-error on else-statement(line 12) while the fact
> is that error is on if-statement(line 9).
>
> Is there some bug or do I have to learn other way interpreted error
> messages?
>
> My code:
> ===============
> #! /usr/bin/awk -f
> # ~bin/iftest
> #
> {
> #printf "%s %s %s %s \n", ARGV[0], ARGV[1], ARGV[2], ARGV[3]
>
> #if (NF == 0) print "usage iftest [1 | anything]"
>
> If ($1 == 1)
> {print "number one"
> printf "%s\n", $0}
> else
> {if (NF == 0)
> {print "empty row"}
> else
> {print "non one"
> printf "%s\n", $0}}
> }
> ===============
> running code gives:
> ========
> iftest test
> awk: /mnt/L6EVM/seppo/bin/iftest.error:12: else
> awk: /mnt/L6EVM/seppo/bin/iftest.error:12: ^ syntax error
> ========
I haven't checked the grammar, but up to line 11 it would be valid
syntax ("If" is just an uninitialized variable).
--
D.