This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Optional Arguments (was Re: CVS script)


>>>>> "TP" == Tim Pierce <twp@skepsis.com> writes:

  TP> I'm unhappy with all of the conventions I've seen for handling
  TP> this matter. It feels as if we've painted ourselves into a
  TP> corner. To my knowledge, no other scripting language in common
  TP> use requires any special syntax for #! interpolation, such as
  TP> the #! ... !# block comment syntax introduced by SCSH. That kind
  TP> of means that our current convention is a wart.
  TP> 
  TP> I'd be more comfortable if we could adopt something like:
  TP> 
  TP> 	#! as the first two characters in a file represent
  TP> 	a comment until end-of-line.
  TP> 
  TP> ... with some appropriate backward compatibility to handle the
  TP> #! ... !# syntax that we presently use. Then we could adopt the
  TP> same argument-processing mechanisms as existing Unix
  TP> interpreters. I think that if we make the script invocation much
  TP> more complex than this, it will discourage people from using
  TP> Guile -- it's a minor inconvenience, but feels very unwieldy.

Here is an extract from the scsh manual, which provides a rationale
for the meta-args system:

      Unfortunately, the Unix exec(2) syscall's support for scripts is
      not very general or well-designed. It will not handle multiple
      arguments; the #! line is usually required to contain no more
      than 32 characters; it is not recursive. If these restrictions
      are violated, most Unix systems will not provide accurate error
      reporting, but either fail silently, or simply incorrectly
      implement the desired functionality. These are the facts of Unix
      life.

I don't know to what extent this comment applies to modern Unix
systems, but please note that the Perl documentation says (extracted
from perldoc perlrun):

      Because many operating systems silently chop off kernel
      interpretation of the #! line after 32 characters, some switches
      may be passed in on the command line, and some may not; you
      could even get a "-" without its letter, if you're not careful.

Perl's "solution" is very complex, allowing monstrosities like

        #!/bin/sh -- # -*- perl -*- -p
        eval 'exec /usr/bin/perl $0 -S ${1+"$@"}'
            if $running_under_some_shell;

I prefer scsh's approach.

-- 
Eric Marsden
emarsden @ mail.dotcom.fr
It's elephants all the way down