Awk bug+fix

David Scheibelhut david at iwu1a.UUCP
Wed Mar 7 10:45:58 AEST 1984


The complaint was that the AWK statement:

	print "data" > "file"

sets the file to zero length only if the print is the first to write
to the file.  This behavior can be considered a bug or feature depending
on the point of view.  Because subsequent prints append to the file one
need not include special code to initialize the file at the start of
execution.  Instead, by using ">" on all print statements, the file is
initialized without special code and contains all output from the last run,
the most common need in AWK's transaction-oriented environment.

On the other hand these semantics are different those of the shell
(where AWK acquired ">") and do not allow AWK to clear a file.  Which
is best?  AWK documentation is vague and allows both interpretations.
Thus the proposed change to AWK is not a bug fix but a change to a working
tool.  Because this change will break many existing AWK programs (including
many of mine) and because AWK has been quite static (the latest documentation
being written about six years ago) I urge that this "bug" not be fixed.

Similar arguments can be made about the other "bugs" which were discussed:
the current implementation has advantages and the documentation, although
ambiguous, allows the current implementation.

	David Scheibelhut



More information about the Comp.unix.wizards mailing list