How can I get the command line arguments in (specifically in GNU, if there are any differences) Common Lisp?
+5
A:
http://cl-cookbook.sourceforge.net/os.html provides some insight
(defun my-command-line ()
(or
#+SBCL *posix-argv*
#+LISPWORKS system:*line-arguments-list*
#+CMU extensions:*command-line-words*
nil))
is what you are looking for, I think.
mog
2009-06-20 15:25:46
(or FOO nil) is equivalent to FOO, is it not?
Luís Oliveira
2009-06-21 15:42:35
Yes, but when you have your FOO conditionally read, it's, possibly, good to have a fall-back. But, then, the value of (or) is, not entirely surprising, NIL (just as the value of (and) is T).
Vatine
2009-06-21 19:56:21
+2
A:
I'm assuming that you are scripting with CLisp. As described here, you can create a file containing
#! /usr/local/bin/clisp
(format t "~&~S~&" *args*)
Make it executable by running
$ chmod 755 <filename>
Running it gives
$ ./<filename>
NIL
$ ./<filename> a b c
("a" "b" "c")
$ ./<filename> "a b c" 1 2 3
("a b c" "1" "2" "3")
anderstornvig
2009-06-20 16:08:57
+3
A:
Are you talking about Clisp or GCL? Seems like in GCL the command line arguments get passed in si::*command-args*
.
js
2009-06-20 17:23:09