> > the method used by FBSD 2.2.7 seems the most sane to me,
> > where execve's argv[] is loaded by each whitespace
> > seperated element after the shebang,
> > then by command line options.
> >
> > 1.  it is flexible.
> > 2.  it functions intuitively.
> > 3.  i don't think it breaks less flexible methods.
> 
> It also suffers from problems with arguments that are meant to include
> spaces, like:
> 
>       #!/bin/sh "hello world" "foo bar"
> 
> Without a fully functional sh(1)-like parser, any solution that does
> magic with argv[] is incomplete :-(

Apologies for a delayed response.
This concerned how to load execve()'s argv[] array
when parsing the 'shebang' line of a script, ie:
whether to pass everything after '#!/interpeter'

1.  as one string into execve()'s argv[] array, as some systems do, or
2.  as individual arguments, as exist after #!/interpreter, separated
    by whitespace.

Bug report 16383 showed the variance in the various UNIX's
of how this is done.  Orginal SysV specs say to load '1 argument'
only after #!/interpreter, leaving it ambiguous as to whether
the '1 argument' is the 1st whitespace separated argument,
or whether it is everything after #!/interpreter as one string.
Posix and SUSv3 don't say anything about how to load execve()'s
argv[] array after #!/interpreter, and seem to leave it to
"whatever is the most intelligent way".

I suggested it made more sense as FBSD 2.2.7 used to do it,
where execve()'s argv[] array was loaded contiguously with
whitespace separated elements, so one could use constructs
such as "#!/bin/sh /script-preprocessor options", and to
allow "#!/interpreter opt1 opt2" and "#!/interpreter opt1 arg1"
type constructs, things that intuitively work as one would
expect on a command line, since there didn't appear to be
any penalty for allowing this flexibility.

A plausible argument was given in response:

>       #!/bin/sh "hello world" "foo bar"

I repond as follows:  that's something only a Windoze user would think of
doing! :)  Unix users don't put whitespace in filenames, nor would they create
options to programs that contain whitespace.  Also, to load:

'"hello world" "foo bar"'

as one string, breaks it's purpose anyway.  it is a bizarre example that has
little practical value, and can be easily compensated for by getting rid of
whitespace in a filename, in the bizarre case where it may exist as such.
Finally, to be slightly extreme with a tiny performance penalty, a beginning
and ending quote in a string could be check for and respected by execve()'s
code that fills argv[].

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-questions" in the body of the message

Reply via email to