[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Scheme-reports] command-line and invocation manner
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
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
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.
Scheme-reports mailing list