root@investor.UUCP (Bob Peirce) (10/23/87)
Older versions of awk would accept the following: 'BEGIN { stuff }{ more stuff }' New awk doesn't like "}{". However, this is not a bug. The manual states on p.22 that "The opening brace of an action must be on the same line as the pattern it accompanies." The implied pattern here is all input lines so, technically, the oening brace should be on a line by itself. Be that as it may, old awk scripts may break on this. -- Bob Peirce, Pittsburgh, PA 412-471-5320 uucp: ...!{allegra, bellcore, cadre, idis, psuvax1}!pitt!investor!rbp NOTE: Mail must be < 30K bytes/message
drw@culdev1.UUCP (Dale Worley) (10/26/87)
root@investor.UUCP (Bob Peirce) writes: > 'BEGIN { > stuff > }{ > more stuff > }' > > The manual > states on p.22 that "The opening brace of an action must be on the > same line as the pattern it accompanies." Eh? As far as I can tell, the pattern is an implied "all lines", physically represented by the null string immediately preceeding the open brace. And that null string is on the same line as the open brace. What am I missing? Dale -- Dale Worley Cullinet Software ARPA: culdev1!drw@eddie.mit.edu UUCP: ...!seismo!harvard!mit-eddie!culdev1!drw If you get fed twice a day, how bad can life be?
allbery@ncoast.UUCP (Brandon Allbery) (10/31/87)
As quoted from <1697@culdev1.UUCP> by drw@culdev1.UUCP (Dale Worley): +--------------- | root@investor.UUCP (Bob Peirce) writes: | > 'BEGIN { | > stuff | > }{ | > more stuff | > }' | > | > states on p.22 that "The opening brace of an action must be on the | > same line as the pattern it accompanies." | | Eh? As far as I can tell, the pattern is an implied "all lines", | physically represented by the null string immediately preceeding the | open brace. And that null string is on the same line as the open | brace. | What am I missing? +--------------- That the format of an awk "rule" is pattern action \n In particular, the pattern MUST be the first thing on the line. I have been writing awk scripts with this in mind the whole time that I have used awk; as a result, my scripts are compatible. Using undocumented behavior is a good way to be burned by changes to a program. -- Brandon S. Allbery necntc!ncoast!allbery@harvard.harvard.edu {harvard!necntc,well!hoptoad,sun!mandrill!hal,uunet!hnsurg3}!ncoast!allbery "Uncle _who_?" -- Lt. Worf ^^^^^^^^^^^^^ NOTE NEW PATH!