[R6RS] Scripts vs. S-expression library names (not)

dyb at cs.indiana.edu dyb at cs.indiana.edu
Sun Jul 30 15:53:06 EDT 2006

> I didn't think this through yesterday: It basically doesn't matter
> what's after the #!/usr/bin/env in the first line of a script.  Unix
> might parse it in an arbitrary way (splitting at the spaces usually),
> but the Scheme script interpreter can and should re-read that first
> loine anyway, ignoring what's in argv.

Actually, we may not be able to put anything but scheme-script after
/usr/bin/env.  I just ran the following experiment on two linux's (Redhat
and Gentoo), FreeBSD, SunOS, and MacOS X.

    echo 'echo $# $*' > scheme-script
    echo '#!/usr/bin/env scheme-script (my script) bar' > foo
    chmod +x scheme-script foo

Here are the results:

  Redhat 9:   /usr/bin/env: scheme-script (my script) bar: No such file or directory
  Gentoo:     /usr/bin/env: scheme-script (my script) bar: Permission denied
  FreeBSD 6:  env: scheme-script (my script) bar: No such file or directory
  SunOS 5.8:  1 ./foo
  MacOS 10.4: 4 (my script) bar ./foo

The Linux and FreeBSD results are essentially the same and indicate that
/usr/bin/env is handed the entire rest of the command line as a single
argument.  Under SunOS and MacOS X, the trick works, but the command
line arguments are different.

Maybe we should switch to something like this:

   #!/usr/bin/env scheme-script\r #!r6rs <library-name> <entry-name>


More information about the R6RS mailing list