Awk bug

Bill Vaughn bill at ur-cvsvax.UUCP
Fri Sep 6 08:21:24 AEST 1985


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    \
---------------------------------



More information about the Net.bugs mailing list