[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: awk: $0 != $ 0

From: Paul Eggert
Subject: Re: awk: $0 != $ 0
Date: Sun, 26 Nov 2006 10:16:08 -0800
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux)

Ralf Wildenhues <address@hidden> writes:

> Well, seems '$ 0' isn't quite the same as '$0', at least with Solaris
> /bin/awk:

Yes, I reproduced that issue with Solaris 10.  My guess (I haven't
looked at the Solaris source) is that plain 'print' prints the
original input line, not $0, and that the Sun maintainers put in a
'can't set $0' diagnostic so that users were warned about the problem,
but they didn't catch all the cases so the warning isn't always made.

> The following one is the most interesting: with one Solaris 5.8 host,
> I get an infinite loop and no output, on another 5.8 host I get:
> $ awk '{ $ 0 = $ 0 "x" $ 0 ; print }' <
> @ac_Dummy_001@
> @f1@

I get the latter, on both Solaris 8 and 10.  With the infinite-loop
host, has Sun patch 111111-06 (dated 2006-04-10) been installed?  It
seems relevant.

As you mentioned, the workaround is easy.  For Awk code that needs to
modify the entire input line, I typically do this:

  line = $0

and then modify and print 'line' rather than trying to set '$0'.  This
is more portable, and the code is saner anyway.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]