bill@ur-cvsvax.UUCP (Bill Vaughn) (09/06/85)
A bug in awk which I thought had been fixed seems to have reappeared in another situation. It involves the string $0 and how the modification of individual fields affect it. It seems that the assignment of $0 to a variable has not been covered by the previous fix. But then, a bare 'print' statement changes $0 to what one expects it to be! Check out the following script. (blank lines inserted for readability) Script started on Thu Sep 5 17:43:58 1985 11> cat /tmp/awks {$1=""; x[1]=$0; print x[1]}\ {print}\ {y=$0; print y} 12> echo 1 2 3 | awk -f /tmp/awks 1 2 3 2 3 2 3 13> cat /tmp/awks1 {$1=""; print}\ {x[1]=$0; print x[1]}\ {y=$0; print y} 14> echo 1 2 3 |awk -f /tmp/awks1 2 3 2 3 2 3 15> cat /tmp/awks2 {$1=""; y=$0; print y}\ {print}\ {x[1]=$0; print x[1]} 16> echo 1 2 3 |awk -f /tmp/awks2 1 2 3 2 3 2 3 17> script done on Thu Sep 5 17:49:04 1985 Does anybody know whats going on here? If it's relevant, I'm running 4.2bsd on a 750. Thanks _________________________________ \ Bill Vaughn / \ Center for Visual Science / / University of Rochester \ / rochester!ur-cvsvax!bill \ ---------------------------------
pjbk@hwcs.UUCP (04/17/86)
Our version of awk does not allow one to use a field specified by a numerical expression as the left hand side of an expression. The file below will pass the standard input through unmodified, although it is designed to replace the last field in each record with "LAST FIELD". Is this a bug or a feature? ----------------------- { $NF = "LAST FIELD" print} ----------------------- -- Peter King, Heriot-Watt University JANET: pjbk@uk.ac.hw.cs ARPA: pjbk@cs.hw.ac.uk or - pjbk%cs.hw.ac.uk@ucl-cs UUCP: ..!ukc!cs.hw.ac.uk!pjbk
gwyn@brl-smoke.UUCP (04/21/86)
In article <800@brahma.cs.hw.AC.UK> pjbk@cs.hw.ac.uk (Peter King) writes: >The file below will pass the standard input through unmodified, >although it is designed to replace the last field in each record >with "LAST FIELD". Is this a bug or a feature? > { $NF = "LAST FIELD" > print} Must be a bug; it works here (SVR2 + bug fixes). Make sure the shell does not mess with the special characters (enclose the whole expression in 'quotes').
pdg@ihdev.UUCP (P. D. Guthrie) (04/22/86)
In article <800@brahma.cs.hw.AC.UK> pjbk@cs.hw.ac.uk (Peter King) writes: >Our version of awk does not allow one to use a field specified >by a numerical expression as the left hand side of an expression. > >The file below will pass the standard input through unmodified, >although it is designed to replace the last field in each record >with "LAST FIELD". Is this a bug or a feature? > ----------------------- > { $NF = "LAST FIELD" > print} This works fine for me, so you must have a bug in your release. -- Paul Guthrie `When the going gets weird, ihnp4!ihdev!pdg The weird turn pro' - H. Thompson