AWK brain damage

kg at hplabs.UUCP kg at hplabs.UUCP
Thu Dec 15 15:41:33 AEST 1983


In (at least) 4.1BSD and System 5 awk:
The following awk script demonstrates three bugs...
END {
	print "Hello" > "file"
	print "cat file" | "/bin/sh"
	print "Folks" > "file"
    }

1. The second > appends to file rather than recreating it.
2. The piped command of line two is asynchronous and causes the 
   two lines of the file, rather than the first line only, to be output.
3. Due to the asynchrony of the second line, awk exits before the
   piped command of line two completes.

Reading the code makes it obvious that they are intentionally trying to
keep files (pipes) open, for efficiency, perhaps, although the result
is totally bogus.  If Aho, Kernighan, or Weinberger read this net trash 
would you comment on this please?
-- 
Ken Greer



More information about the Comp.unix.wizards mailing list