[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Scheme-reports] (command-line) needs to specify argv[0] behavior
- To: scheme-reports@x
- Subject: [Scheme-reports] (command-line) needs to specify argv[0] behavior
- From: Per Bothner <per@x>
- Date: Wed, 03 Aug 2011 11:15:47 -0700
This has been discussed before, but I don't see a ticket for it.
The definitions of (command-line) is:
Returns the command line arguments passed to the process
as a list of strings.
It needs to clarify if this list includes the command used to
invoke the process - i.e. C's argv[0].
Making it implementation-dependent makes it useless.
However, it is possible to make the first car be implementation-dependent.
I.e. (car (command-line)) corresponds to C's argv[0], if known,
and is "" if unknown.
A complication is there may be multiple command names:
/usr/local/bin/myscheme myprog.scm a b c
where myscheme is the Scheme "interpreter", myprog.scm is the Scheme
application, and (a b c) are the actual use commands. In this case,
what should (command-line) return?
Similarly:
java -classpath kawa.jar -Xmx120 kawa.repl a b c
So perhaps command-line should only return "user" command-line arguments.
I.e. in the above examples:
("a" "b" "c")
I suggest:
The result should not include the command name used to invoke the
process,
or (if the process is a Scheme evaluator) the name of the Scheme file
being
evaluated or evaluator-specific options.
Perhaps there should be a separate function to get the "invocation
arguments":
(command-invoker) ==> ("/usr/local/bin/myscheme" "myprog.scm")
(command-invoker) ==> ("java" "-classpath" "kawa.jar" "-Xmx120"
"kawa.repl")
Some implementations (including Kawa) may have difficulty implementing
command-invoker.
Allowing command-line (and command-invoker) to return a list of
immutable strings
(like symbol->string does) would avoid the need for an extra copy operation
on Kawa, but that is pretty minor.
--
--Per Bothner
per@x http://per.bothner.com/
_______________________________________________
Scheme-reports mailing list
Scheme-reports@x
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports