nawk naughtyness noted
DanKarron at UCBVAX.BERKELEY.EDU
DanKarron at UCBVAX.BERKELEY.EDU
Thu Nov 29 19:21:37 AEST 1990
This to report that passing a variable assignment statment to nawk
does not work if there is an underscore in the var name.
IRTFM, and the AWK Programming language, by A.V.A, B.W.K and P.J.W says on
page 63, Command-Line Variable Assignmens,
... If a filename has the form VAR=text, however, it is
treated as an assignment of text to var, and performed at the time when
that argument would be accessed as a file. This type of assignment allows
variables to changed before and after a file is read.
IRTFM, and the nawk man page says Parameters, in the form x=...y=... may
be passed to nawk are built-in vars (see list below).
(list below deleted, but it is short and contains what you would expect)
SO: The actual behavior is that the AWK described in the awk book acts
like it should, but the behavior is a superset of the behavior in the
man page. I have found that it works
for small var names, but breaks for long var names containing underscores.
I can live with that, but I just thought I would note it for eternity.
Here is the sample code:
nawk '
{
if($0~/^#\ CONFIGURATION\ .*/)
{
printf("%s %s Configured %s\n",$1,$2,FILENAME);
getline
while($0!~/^#\ END\ CONFIGURATION .*/)
{
if($1~/^SUBJECT=.*/)printf("SUBJECT=%s\n",SUBJECT);
else if($1~/^FROM=.*/)printf("FROM=%s\n",FROM_PERSON);
else if($1~/^VERSION=.*/)printf("VERSION=%s\n",VERSION);
else printf("%s #???? not known in CONFIGURATION AREA\n",$0);
getline
}
printf("%s %s %s Configured %s\n",$1,$2,$3,FILENAME);
}
else printf("!%s\n",$0);
}' SUBJECT=roses VERSION=1.0 FROM_PERSON="karron at nyu.edu" $HOME/D.DirectoryMail
er/UnPackMail.sh
Cheers from Dan, who squashes all bugs, even those that are not there.
+-----------------------------------------------------------------------------+
| karron at nyu.edu (E-mail alias that will always find me) |
| * Dan Karron, Research Associate |
| . . . . . . . . . . . . . . * New York University Medical Center |
| 560 First Avenue \*\ Pager <1> (212) 397 9330 |
| New York, New York 10016 \**\ <2> 10896 <3> <your-number-here> |
| (212) 340 5210 \***\_________________________________________ |
| Main machine: karron.med.nyu.edu (128.122.135.3) IRIS 85GT |
+-----------------------------------------------------------------------------+
More information about the Comp.sys.sgi
mailing list