Re: [SLUG] Awk Question

From: Paul Braman (aeon@tampabay.rr.com)
Date: Tue Nov 06 2001 - 18:02:32 EST


On Mon, 5 Nov 2001, Paul M Foster wrote:

> This is an obscure one, just for you awk gurus.
>
> I have some scripts which begin:
>
> #!/bin/mawk -We

There are two reasons why this sequence will work:

1) The kernel, when passed the script, will look at the first few bytes
in the file and say, "Hey, I've got a she-bang here so let me try and
launch the interpreter which is specified on the rest of the line and pass
it the *complete* file."

2) The interpreter in question recognizes "#" as the start-of-comment
marker and effectively ignores the first line in the file.

If there is a case where it is not working you must consider that:

1) The interpreter line is incorrect, like when mawk is linked to gawk
and passing some options it doesn't know about, or simply cannot be found
at the given path.

2) The script is not set executable. (Simple check, but happens a lot.)

3) The interpreter you are trying to use is trying to directly interpret
the first line and considers "#" something other than a comment-starter.

4) The interpreter you are trying to use does not support the way the
kernel is trying to run it. (I'm almost certain the kernel constructs a
command that says "<interpreter> <script filename>" instead of passing the
file in as standard input.)

Paul Braman
x5273



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 16:59:08 EDT