Strange behaviour of awk
Joe Smith
jes at mbio.med.upenn.edu
Tue Feb 28 09:56:48 AEST 1989
>... I hesitate to call it a "bug" unless some
>documentation on "old awk" says $0 is reconstructed; the AWK book
>describes only "new awk", and describes a *lot* of stuff that doesn't
>work in "old awk" because it wasn't in "old awk".
Certainly an important point I didn't mention. However, I think
it's safe to say that having a variable change its contents when it's
printed is a very surprising and undesirable "feature" of a
programming language.
I also meant to mention that GNU-awk handles the test case just fine.
It chokes, however, on slightly more complicated tests, so it may not
handle the original poster's problem:
$ gawk '{ $1 = ""; print $0}'
1 2 3
2 3 ok
$ gawk '{ $1 = ""; x = $0; print $0}'
1 2 3
2]yNzp3]y|@N||@}d|pN|0 oops!
2 3N|4
2 3
--
jes at mbio.med.upenn.edu
University of Pennsylvania
Dept. of Biochemistry and Biophysics
233 Anatomy-Chemistry
Philadelphia, PA 19104-6059
(215) 898-8348
More information about the Comp.unix.questions
mailing list