Subject: Re: Changing exec's #! behavior
To: Jason R Thorpe <thorpej@zembu.com>
From: Jim Bernard <jbernard@mines.edu>
List: tech-kern
Date: 06/13/2000 14:34:53
On Tue, Jun 13, 2000 at 11:29:59AM -0700, Jason R Thorpe wrote:
> and the following on NetBSD:
> 
> argv[0] = /usr/bin/env
> argv[1] = perl -w
> argv[2] = ./foo.pl
> argv[3] = one
> argv[4] = two
> argv[5] = three 
> 
> env(1) subsequently complains that it cannot exec "perl -w" because it
> doesn't exist.
> 
> 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.
> 
> 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.

  I'd like to see this fixed, but wouldn't it be more intuitively obvious
to pass all the arguments separately?  Like:

 argv[0] = /usr/bin/env
 argv[1] = perl
 argv[2] = -w
 argv[3] = ./foo.pl
 argv[4] = one
 argv[5] = two
 argv[6] = three 

The idea that only one gets passed seems awful, no matter how you define it.

  FWIW: Linux (RH 6.2) and AIX (4.3.3) behave like NetBSD (at least the perl
test bombs out in the same way: "env: perl -w: No such file or directory",
or some equivalent).