bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: env behavior incorrect


From: Bob Proulx
Subject: Re: env behavior incorrect
Date: Mon, 2 Jun 2003 23:19:01 -0600
User-agent: Mutt/1.3.28i

Jens Elkner wrote:
> 'Paul Jarc wrote:'
> > scripts are limited to only one argument in the "#!" line
> > after the interpreter.
> 
> Hmm, have you any pointer to a guideline or standard for this. Currently
> I have not found anything wrt. #! interpreter arg, expect in the Solaris
> exec manpage :(

The #! syntax is generally called the Berkeley #! hack.  Or the
Berkeley shebang hack.  It was a wonderful improvement over not having
it at all.  But is still considered a hack because it has many
limitations.  One is that only one argument is allowed.  Some
operating systems have a limit of not more than 32 characters for the
line allowed.  Another is that it must be a binary program and not
another shell interpreter.  These have nothing to do with the 'env'
command itself.  You may substitute any command there such as my
favorite which is 'echo' and you will see the same limitation imposed
by the underlying operating system.

W. Richard Stevens documents this best in Advanced Programming in the
UNIX Environment in a section on "interpreter files".  The HP-UX man
pages document this in the "man exec" page.  Most basic shell
programming texts should document this when talking about the #! line.
The Programming Perl "camel" book documents this but gets the details
wrong which you will find if you experiment with it and I won't detail
that here.  The possibilities are large and my experience is limited.

You might check out the UNIX FAQ page.  Here is a pointer to one copy
of it.  Search for "3.16) Why do some scripts start with #! ... ?".

  ftp://rtfm.mit.edu/pub/usenet/news.answers/unix-faq/faq/part3

But as to the standards documentation they say little.  I could find
nothing authoritative.

Found in the exec man page on some systems:

      The initial line of a script file must begin with #! as the first two
      bytes, followed by zero or more spaces, followed by interpreter or
      interpreter argument, as in:

           #! interpreter [argument]

      One or more spaces or tabs must separate interpreter and argument.
      The first line should end with either a newline or a null character.

Since BSD was the original source to this I imagine most people just
reference the BSD kernel source code as the authoritative reference.
What it does is what it does, no more and no less.

Bob




reply via email to

[Prev in Thread] Current Thread [Next in Thread]