Article View: comp.std.unix
Article #847Re: awk syntax
From: Arnold Robbins
Date: Thu, 16 May 1991 14:35
Date: Thu, 16 May 1991 14:35
62 lines
3589 bytes
3589 bytes
Submitted-by: arnold%audiofax.com@mathcs.emory.edu (Arnold Robbins)
>In article <1991May14.185737.15746@uunet.uu.net> arnold@audiofax.com writes:
>> One of the things that happened when new awk was first realeased was a lot
>> of cleaning up and consistencizing (if I may coin a term) of the awk
>> language.
In article <1991May15.165824.6896@uunet.uu.net> peter@ficc.ferranti.com (Peter da Silva) writes:
>I don't see how that makes things any more consistent. If you look at the
>grammer there's no ambiguity that needs to be resolved by adding that
>semicolon. Does anyone have an idea what the reasoning behind this was?
>To me, it adds confusion by treating a block as a statement.
This is getting off the topic of standards, but what the heck. You
ommitted my rationalization of the consistency. To rephrase: statements
at the rule level should be consistent with statements inside an action.
Statements in a action are separated by newline or semi-colon, therefore
rules (patterns plus actions) should also be separated by newlines or
semi-colons. It is illegal to type
{ i = 1 j = 2 }
in an action without the semicolon or newline between the assignments.
Therefore it "should" be illegal to type rules without the separator.
(So yes, block are statements. This makes sense, since they're executed
in the order they occur in the program.)
As I also mentioned, modern implemenations of 'nawk' (V.4 nawk, gawk)
accept rules with or without the semicolon, so it doesn't really matter.
(Many C compilers continue to accept `i =+ 1' but that doesn't make it
good programming practice...)
>Oh, and my V.3.2 system has no problem with that:
>
>% ls -l | awk 'NF==9 { h[$3] += $5 } END {for(i in h) print i,h[i]}'
>root 7985
>peter 731662
You typed "awk", no 'n'. My example used "nawk", with an 'n'. Try
awk 'BEGIN { foo() }
function foo () { print "hi" }'
on your V.3.2 system and watch "awk" (no 'n') barf all over your screen.
We're talking two very different animals here.
For whatever it's worth, the V.3.2 nawk man page said that in the "next
major release" nawk would become 'awk' and old awk would become 'oawk'.
This doesn't seem to have happened in V.4. It probably never will in
System V. 4.4BSD will most likely ship gawk for it's version of awk.
Next topic, please?
--
Arnold Robbins AudioFAX, Inc. | Threads are the
2000 Powers Ferry Road, Suite 200 / Marietta, GA. 30067 | lack of an idea.
INTERNET: arnold@audiofax.com Phone: +1 404 618 4281 | -- Rob Pike
UUCP: emory!audfax!arnold Fax-box: +1 404 618 4581 |
[ He's right. I've cross-posted this to comp.unix.questions, with
followup's directed there. -- mod ]
Volume-Number: Volume 23, Number 72
Technical Details
Message-ID:
<1991May17.011011.6422@uunet.uu.net>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!uunet.UU.NET!sefReferences:
<1991May13.222855.9433@uunet.uu.net> <1991May14.185737.15746@uunet.uu.net> <1991May15.165824.6896@uunet.uu.net>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!uunet.UU.NET!sef From: arnold%audiofax.com@mathcs.emory.edu (Arnold Robbins) Newsgroups: comp.std.unix,comp.unix.questions Subject: Re: awk syntax Summary: Does anyone really care any more? Message-ID: <1991May17.011011.6422@uunet.uu.net> Date: 16 May 91 14:35:41 GMT References: <1991May13.222855.9433@uunet.uu.net> <1991May14.185737.15746@uunet.uu.net> <1991May15.165824.6896@uunet.uu.net> Sender: usenet@uunet.uu.net (UseNet News) Reply-To: arnold@audiofax.com Followup-To: comp.unix.questions Organization: AudioFAX, Inc., Atlanta Georgia Lines: 62 Approved: sef@uunet.uu.net (Moderator, Sean Eric Fagan - comp.std.unix) Originator: sef@uunet.UU.NET Nntp-Posting-Host: uunet.uu.net X-Submissions: std-unix@uunet.uu.net