Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!eecae!netnews.upenn.edu!jes From: jes@mbio.med.upenn.edu (Joe Smith) Newsgroups: comp.unix.questions Subject: Re: Strange behaviour of awk Message-ID: Date: 27 Feb 89 23:56:48 GMT References: <497@eutrc3.UUCP> <1085@auspex.UUCP> Sender: news@netnews.upenn.edu Organization: University of Pennsylvania, Philadelphia, PA Lines: 31 In-reply-to: guy@auspex.UUCP's message of 27 Feb 89 19:03:08 GMT >... 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@mbio.med.upenn.edu University of Pennsylvania Dept. of Biochemistry and Biophysics 233 Anatomy-Chemistry Philadelphia, PA 19104-6059 (215) 898-8348