[comp.unix.ultrix] awk -f - in Ultrix 4.0

abby@luna.math.ucla.edu (Abby Hossein) (03/21/91)

Does anyone know why, in 4.0 on DEC5000, "awk -f - filename" produces 
"Can't open -"!? The man page says it supports the "-" option but then 
again, this is not the first time I see a man page lie!


--
============================================================================
| Abby Hossein (UCLA Math. Dept. MS6221)|abby@math.ucla.edu|(213) 825-5101 |
| 405 Hilgard Ave. LA. CA 90024-155505  |abby%math.ucla.edu@INTERBIT       |
============================================================================

chang@osc.COM (Lai-Chang Woo) (03/23/91)

In article <1991Mar20.171431.13307@math.ucla.edu> abby@luna.math.ucla.edu (Abby Hossein) writes:
>Does anyone know why, in 4.0 on DEC5000, "awk -f - filename" produces 
>"Can't open -"!? The man page says it supports the "-" option but then 
>again, this is not the first time I see a man page lie!

This is not the only thing that breaks in awk either.  Dump awk and just use
nawk instead.  Your life will be much easier.

					Lai-Chang Woo
					chang%osc.osc.com@uunet.uu.net

grr@cbmvax.commodore.com (George Robbins) (03/25/91)

In article <4678@osc.COM> chang@osc.UUCP (Lai-Chang Woo) writes:
> In article <1991Mar20.171431.13307@math.ucla.edu> abby@luna.math.ucla.edu (Abby Hossein) writes:
> >Does anyone know why, in 4.0 on DEC5000, "awk -f - filename" produces 
> >"Can't open -"!? The man page says it supports the "-" option but then 
> >again, this is not the first time I see a man page lie!
> 
> This is not the only thing that breaks in awk either.  Dump awk and just use
> nawk instead.  Your life will be much easier.

That's great, but the last time I tried nawk on a MIPS based system,
it blew off with some kind of fatal alignment errors.  However, the
current version of GNU awk (gawk 2.11) seems to work well enough for
most purposes and also emits usable error messages.

It is also mildly amusing to note that nawk doesn't support "-f -"
either, although gawk tries to, but seems to fail if both "program"
and input are read from stdin...

Note: while the man text suggests that '-' refers to stding, the usage
line does not show it as an agrument to the "-f" option.

     awk [-Fc] [-f prog] [-] [file...]

Normally, I just use the standard bourne shell continuation of quoted
strings when I want the script in-line, but I can see where that might
not serve if you want to pipe a generated script into awk - temp files,
yeech!

-- 
George Robbins - now working for,     uucp:   {uunet|pyramid|rutgers}!cbmvax!grr
but no way officially representing:   domain: grr@cbmvax.commodore.com
Commodore, Engineering Department     phone:  215-431-9349 (only by moonlite)

frank@croton.nyo.dec.com (Frank Wortner) (03/26/91)

In article <20082@cbmvax.commodore.com>, grr@cbmvax.commodore.com
(George Robbins) writes:

> It is also mildly amusing to note that nawk doesn't support "-f -"

... but the ULTRIX nawk man page explicitly says that it does:

	"There are two ways to specify the nawk program:

	(a) ...

	(b) By using the -f programfile option (where programfile con-
	tains the nawk program).  More than one -f option can appear
	on the command line.  The program will consist of the con-
	catenation of the contents of all the specified program-
	files.  You can use - in place of a file name, to obtain
	input from the standard input."

					Frank

grr@cbmvax.commodore.com (George Robbins) (03/27/91)

In article <2182@riscy.enet.dec.com> frank@croton.nyo.dec.com (Frank Wortner) writes:
> In article <20082@cbmvax.commodore.com>, grr@cbmvax.commodore.com
> (George Robbins) writes:
> 
> > It is also mildly amusing to note that nawk doesn't support "-f -"
> 
> ... but the ULTRIX nawk man page explicitly says that it does:
> 
> 	"There are two ways to specify the nawk program:
> 
> 	(a) ...
> 
> 	(b) By using the -f programfile option (where programfile con-
> 	tains the nawk program).  More than one -f option can appear
> 	on the command line.  The program will consist of the con-
> 	catenation of the contents of all the specified program-
> 	files.  You can use - in place of a file name, to obtain
> 	input from the standard input."

Which version of Ultrix adopts nawk?  My info pertained to the standard
AT&T version (SVR3.2 I think) that I tried to port to Ultrix...  The Ultrix
man page doesn't seem to match that or the SVr4 man page, which is still
ambiguous as to wheter the - applies to the -f, or just "input".

Does the "-f -" really work, or did some Ultrix person attempt to clarify
the man page and succeed in telling a lie.   8-)

-- 
George Robbins - now working for,     uucp:   {uunet|pyramid|rutgers}!cbmvax!grr
but no way officially representing:   domain: grr@cbmvax.commodore.com
Commodore, Engineering Department     phone:  215-431-9349 (only by moonlite)

frank@croton.nyo.dec.com (Frank Wortner) (03/28/91)

In article <20134@cbmvax.commodore.com>, grr@cbmvax.commodore.com
(George Robbins) writes:
 
> Which version of Ultrix adopts nawk? 

4.0

> Does the "-f -" really work, or did some Ultrix person attempt to clarify
> the man page and succeed in telling a lie.   8-)

Would I lie to you?  ;-)

It really works.  Here's a trivial example.  Notice that I typed the program on
standard input.

Script started on Wed Mar 27 11:50:37 1991
$ nawk -f - /etc/hosts
$1 !~ /#/ {
	print $1
}
^D127.0.0.1
16.69.128.12
16.69.128.17
16.69.128.242
16.70.192.1
16.69.128.21
$ 

script done on Wed Mar 27 11:51:09 1991

chang@osc.COM (Lai-Chang Woo) (03/28/91)

In article <2182@riscy.enet.dec.com> frank@croton.nyo.dec.com (Frank Wortner) writes:
>In article <20082@cbmvax.commodore.com>, grr@cbmvax.commodore.com
>(George Robbins) writes:
>
>> It is also mildly amusing to note that nawk doesn't support "-f -"
>
>... but the ULTRIX nawk man page explicitly says that it does:
>

Besides, I tested it before posting the suggestion to use nawk.

					Lai-Chang Woo

grr@cbmvax.commodore.com (George Robbins) (03/30/91)

In article <4692@osc.COM> chang@osc.UUCP (Lai-Chang Woo) writes:
> In article <2182@riscy.enet.dec.com> frank@croton.nyo.dec.com (Frank Wortner) writes:
> >In article <20082@cbmvax.commodore.com>, grr@cbmvax.commodore.com
> >(George Robbins) writes:
> >
> >> It is also mildly amusing to note that nawk doesn't support "-f -"
> >
> >... but the ULTRIX nawk man page explicitly says that it does:
> 
> Besides, I tested it before posting the suggestion to use nawk.

Well, I tested it also, before saying that it didn't, the only problem
being that your nawk and my nawk were different nawks, since I'm still
running 3.1C and I didn't see nawk in my 4.1 stuff (hidden in /bin 8-).
Sorry for the confusion, just another ultrixism...

-- 
George Robbins - now working for,     uucp:   {uunet|pyramid|rutgers}!cbmvax!grr
but no way officially representing:   domain: grr@cbmvax.commodore.com
Commodore, Engineering Department     phone:  215-431-9349 (only by moonlite)