Ralf Wildenhues <[EMAIL PROTECTED]> 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 }' < dummy.in
> @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