[net.unix-wizards] awk

rob@alice.UUCP (03/04/84)

awk deliberately places all output redirected to the same file name
onto the same file descriptor. it is not a bug; do not change awk's
behaviour.

kg@hplabs.UUCP (Ken Greer) (03/09/84)

	Path: hplabs!hao!seismo!harpo!ulysses!allegra!alice!rob
	Subject: awk
	awk deliberately places all output redirected to the same file name
	onto the same file descriptor. it is not a bug; do not change awk's
	behaviour.

The current (bizarre) action is not documented.  Additionally, the awk
documentation indicates that the >, >>, and | work the same as in
the shell.  So what's the basis of your claim?
-- 
Ken Greer

rob@alice.UUCP (03/09/84)

From the (admittedly most recent) awk reference manual:

Any given file [from > >> or |] is opened only once per execution of
.IT awk
and remains open until 
.IT awk
terminates.

lcc.bob%ucla-locus@sri-unix.UUCP (03/09/84)

From:            Bob English <lcc.bob@ucla-locus>

If you change the behavior of a standard system utility, then you
must be prepared to fix every program written before and after that
uses the standard.  You could, of course, extend "awk" to provide
the service you want (by adding an option, or changing the
syntax), just make sure it's compatible with the rest of the
world.  And be prepared for the screams of those who believe that
no tool can ever be improved.

Alternatively, you can make any changes you want without worrying
about compatibility and call the result son_of_awk.

--bob--

guy@rlgvax.UUCP (Guy Harris) (03/10/84)

It's nice that the current "awk" manual documents the behavior of output
redirection.

*Why didn't the original "awk" manual do this?*  It's sufficiently counter-
intuitive (if you're used to the behavior of output redirection in the
shell) that it shouldn't have gone unmentioned (note the amount of discussion
it has generated, if you don't think it needed to be documented).  I have yet
to see a Bell UNIX release which didn't have at least one significant thing
totally undocumented (did you know that the TCXONC "ioctl" in USG UNIX - S3,
S5, etc. - permits you to suspend and restart *input* as well as output?  The
"arg" values for that are 3 and 4, and it's present in S3 and S5 and documented
in *neither*) - Berkeley documented the "varargs" include file (provides a
mostly-portable way to write routines which take a variable number of
arguments; 1000 thanks due to Mark Horton for documenting it), but I think
there are probably undocumented goodies there too.

Speaking of "varargs", there is an undocumented version of the "*printf" family
in S3 - although not in S5 - which provides the functionality of calling
"_doprnt" directly. Very nice if you want a version of "curses" that works on
systems without "_doprnt"....  The routines are "vprintf", "vfprintf", and
"vsprintf", and they take the same first couple of arguments as their non
"vararg" counterparts, except that they get passed a pointer to the argument
list instead of getting passed the arguments directly.

Also, in all V7 and post-V7 versions of "login" I've seen, the user's login
shell is executed by "execlp", so you can have a shell file as a login shell.
We have actually *used* this feature, and it came in handy (we wanted to
have somebody come into a non-standard shell and have the TZ environment
variable set - this is a misfeature of USG UNIX; you can't use non-standard
login shells unless 1) they know how to set the timezone stuff up, 2) you
recompile "ctime" to default to your timezone and relink *everything* that
is run by that shell, 3) you put in a system call to get the time zone
(like the V7 "ftime" or 4.2BSD "gettimeofday" system calls) and have
"ctime" get the default time zone from that, or 4) you are in the Eastern
Standard Time zone).

Is it just that the person who put in those features never told anybody and
left before they had a chance, and nobody else noticed it and told
the documentation people?  (Hell, if the documentation were better, I suspect
the traffic in "net.unix" and "net.unix-wizards" would drop quite a bit!)

	Guy Harris
	{seismo,ihnp4,allegra}!rlgvax!guy

nather@utastro.UUCP (Ed Nather) (03/16/84)

[]
	From:            Bob English <lcc.bob@ucla-locus>

	If you change the behavior of a standard system utility, then you
	must be prepared to fix every program written before and after that
	uses the standard.  You could, of course, extend "awk" to provide
	the service you want (by adding an option, or changing the
	syntax), just make sure it's compatible with the rest of the
	world.  And be prepared for the screams of those who believe that
	no tool can ever be improved.

	Alternatively, you can make any changes you want without worrying
	about compatibility and call the result son_of_awk.

	--bob--

Too late.  Berkeley already "fixed" awk so it no longer runs many of the
tutorial's examples.  They didn't bother to re-write the tutorial, and they
didn't bother to change the name (to protect the innocent).  They just
call it "awk."

The "awk" distributed with USG System V still works as advertized.

-- 

                                       Ed Nather
                                       ihnp4!{ut-sally,kpno}!utastro!nather
                                       Astronomy Dept., U. of Texas, Austin