[comp.unix.questions] 4.2BSD awk bugs

chris@mimsy.UUCP (Chris Torek) (01/23/88)

In article <14660@beta.UUCP> dph@beta.UUCP (David P Huelsbeck) writes:
>BSD4.2 made some changes to awk.  Since 4.3 came out very shortly
>after I became interested in awk I've never looked to see exactly 
>what they did or why.

It was part of the effort involved in removing *(char *)0 == 0
dependencies.  Someone botched it, though.  Ah well.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris@mimsy.umd.edu	Path:	uunet!mimsy!chris

davel@hpcupt1.HP.COM (Dave Lennert) (01/31/88)

> In article <515@root44.co.uk> you write:
> >	who | awk '{ print $1 | "sort" }'
> >gives the same output as
> >	who | awk '{ print $1 }' | sort
> 
> FYI, the two *don't* give the same results under Ultrix T2.0-1I.

One explanation could be that early versions of awk (e.g., 4.2) do
not wait for all their children to finish before exiting.  So, in
the first example above, the awk could finish while the sort is running.

If stdout is a terminal and BSD job control is active and the LTOSTOP
flag is set, then you won't see any (or complete) output since the
sort will be killed when it attempts output as a background, orphaned
process.

If stdout is a file, then the user (or the next command in the script)
could examine the file before it is completely written by sort.

Now you know why all my scripts look like:

	who | awk '{ print $1 | "sort" }' > tmp
	sleep 60	# hack for awk
	cat tmp

-Dave Lennert   HP    ihnp4!hplabs!hpda!davel