Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!elroy.jpl.nasa.gov!decwrl!pa.dec.com!shlump.nac.dec.com!riscy.enet.dec.com!croton.nyo.dec.com!frank From: frank@croton.nyo.dec.com (Frank Wortner) Newsgroups: comp.unix.ultrix Subject: Re: Ultrix 4.1 /bin/csh / awk bug? Message-ID: <2193@riscy.enet.dec.com> Date: 15 Apr 91 13:33:47 GMT References: Sender: newsdaemon@riscy.enet.dec.com Reply-To: frank@croton.nyo.dec.com (Frank Wortner) Organization: Digital Equipment Corporation Lines: 59 In article , braun@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