Ultrix 4.1 /bin/csh / awk bug?
Frank Wortner
frank at croton.nyo.dec.com
Mon Apr 15 23:33:47 AEST 1991
In article <V4K1Y3Z at dri.com>, braun at dri.com (Kral) writes:
> Can someone tell me if this is a known bug ... It seems that either csh
> or awk is barfing on the '#!' majik number.
Everything is working as documented. Here's a quote from the execve(2)
manual page:
An interpreter file begins with a line of the form ``#! inter-
preter''. When an interpreter file is executed the system exe-
cutes the specified interpreter, giving it the name of the origi-
nally executed file as an argument, shifting over the rest of the
original arguments.
So, if we take your example:
#! /bin/awk
{
print "This is a test."
}
#
and place it in the file test.awk, here is what happens:
The kernel gets an exec-something-or-other system call with
test.awk as an argument.
The loader figures out that this is an interpreter file.
The call is rearranged so that it looks like this:
/bin/awk test.awk
Awk assumes that its first and only argument is a program.
The words "test.awk" do not constitute a valid awk program.
OOPS! Syntax error!
If you want awk to execute your program try making one small
change:
#! /bin/awk -f
instead of
#! /bin/awk
This way, when the loader calls /bin/awk, the result will be:
/bin/awk -f test.awk
and things will work the way you expect.
Hope this clears things up a bit. Have fun!
Frank
More information about the Comp.unix.ultrix
mailing list