Subject: Re: Changing exec's #! behavior
To: Jason R Thorpe <thorpej@zembu.com>
From: Andrew Brown <atatat@atatdot.net>
List: tech-kern
Date: 06/13/2000 16:08:25
>The problem is that BSD and Solaris are defining [arg] differently
>in the #! specification.  In BSD, [arg] is defined as "until the end
>of the line" whereas in Solaris, it's defined as "until the first
>whitespace".

isn't there also a limit on the length of "arg"?  i seem to remember a
32 from somewhere...

>Now, the reason that the -w is seen by perl in the Solaris case is
>because perl *itself* looks at the script for a line that has "#!" and
>"perl" in it, and upon finding it, parses the command line args to
>perl located there itself.

perl *is* wicked, isn't it?  :)

>I've changed NetBSD's exec_script.c to have the Solaris behavior and
>am using it that way in our environment here.  But I'd like to get
>comments on this before I commit the change to the master NetBSD
>sources.

that seem fine to me.  it ought not to break anything that worked so
far.  but i do have a related question:

how hard would it be to have interpreters that used other interpreters
that were not binaries?  eg...why does the following not work?

   % file part2
   part2: a /home/andrew/rot13 script text
   % cat part2
   #!/home/andrew/rot13
   this is 
   a test

   % file /home/andrew/rot13
   /home/andrew/rot13: perl commands text
   % cat rot13
   #!/usr/local/bin/perl -p
   tr/A-Za-z/N-ZA-Mn-za-m/;
   $_=""if(/^\#/);

   % file /usr/local/bin/perl
   /usr/local/bin/perl: NetBSD/i386 demand paged dynamically linked executable not stripped

   % ./part2
   this: Command not found.
   a: Command not found.

-- 
|-----< "CODE WARRIOR" >-----|
codewarrior@daemon.org             * "ah!  i see you have the internet
twofsonet@graffiti.com (Andrew Brown)                that goes *ping*!"
andrew@crossbar.com       * "information is power -- share the wealth."