NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: bin/52623: nonsense error message in awk
The following reply was made to PR bin/52623; it has been noted by GNATS.
From: Robert Elz <kre%munnari.OZ.AU@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc:
Subject: Re: bin/52623: nonsense error message in awk
Date: Mon, 16 Oct 2017 14:15:07 +0700
Date: Mon, 16 Oct 2017 02:05:00 +0000 (UTC)
From: dholland%eecs.harvard.edu@localhost
Message-ID: <20171016020500.E6C587A269%mollari.NetBSD.org@localhost>
| Accidentally writing index[array] instead of array[index] in awk
| causes a nonsense error message.
Not really nonsense...
| awk -F: < /etc/passwd '{ a[$1] = $3; } END { for (k in a) print k[a]; }'
When that is compiled, awk can see from the reference to k[a] that k is
an array. The syntax is all OK, so the compile succeeds.
When it is executed, and we get to the "for (k in a)" we need to assign
the indexes of array a to k, which can't be done, as k is an array.
Hence:
| awk: can't assign to k; it's an array name.
What would you have it do differently?
kre
Home |
Main Index |
Thread Index |
Old Index