Article View: net.bugs
Article #461Awk bug
From: Bill Vaughn
Date: Thu, 05 Sep 1985 22:21
Date: Thu, 05 Sep 1985 22:21
51 lines
1808 bytes
1808 bytes
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 \
---------------------------------
Technical Details
Message-ID:
<222@ur-cvsvax.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!panda!talcott!harvard!seismo!rochester!ur-cvsvax!billShow Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/5/84; site ur-cvsvax.UUCP Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!panda!talcott!harvard!seismo!rochester!ur-cvsvax!bill From: bill@ur-cvsvax.UUCP (Bill Vaughn) Newsgroups: net.bugs Subject: Awk bug Message-ID: <222@ur-cvsvax.UUCP> Date: Thu, 5-Sep-85 18:21:24 EDT Article-I.D.: ur-cvsva.222 Posted: Thu Sep 5 18:21:24 1985 Date-Received: Sat, 7-Sep-85 06:06:48 EDT Distribution: net Organization: Center for Visual Science, U. of Rochester Lines: 51