Re: [Scheme-reports] command-line and invocation manner
Per Bothner 19 Sep 2013 04:56 UTC
On 09/18/2013 05:58 PM, Alex Shinn wrote:
> For SRFI-22 or other shebang scripts, for use 1) you want
> just the script name. For use 2) just the script name will
> also do the right thing. This is what chibi-scheme does.
Kawa supports basic #!-invocation, though it doesn't claim
to support SRFI-22. Instead, the recommended method is
more flexible - see http://www.gnu.org/software/kawa/Scripts.html
Such a script does get the expected result for (cdr (command-line)),
but doesn't set a "nice (car (command-line)):
$ cat ~/tmp/foo.scm
#!/bin/sh
exec /usr/bin/kawa --script2 "$0" "$@"
(format #t "c-l: ~w~%" (command-line))
$ ~/tmp/foo.scm a "c d"
c-l: ("java kawa.repl --connect 53985 --script2
/home/bothner/tmp/foo.scm" "a"
"c d")
The --script2 option causes the Kawa reader to skip the first two lines.
This could be fixed by (for example) having --script2 have the
side-effect of setting a variable checked by the command-line function.
Cleaner might be a new flag that combines the effect of --script2
and setting the program name.
> Compiling to an application (with a static "main" method):
>
> $ kawa --main -C ~/tmp/foo.scm
> (compiling /home/bothner/tmp/foo.scm to foo)
> $ java foo abc "def ghi"
> c-l: ("java foo" "abc" "def ghi")
>
>
> I guess if the OS supports natively running compiled Java
> then this would just be runnable as:
>
> $ foo abc "def ghi"
> c-l: ("foo" "abc" "def ghi")
>
> as in other compiled implementations?
Java is normally compiled to (one or more) .jar files.
An application commonly comes with shell and/or batch
scripts which is a wrapper that invokes the java command
on the .jar file (perhaps with some extra setup). (Compiling
to a native application is unusual. Alas GCJ is not
very active any more.)
I think the thing for Kawa to do is to define a property
(set with a -D option when invoking the JVM), and for
the (command-line) procedure to check if this property is set.
Or some similar convention.
--
--Per Bothner
per@bothner.com http://per.bothner.com/
_______________________________________________
Scheme-reports mailing list
Scheme-reports@scheme-reports.org
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports