Search code examples
command-linelispcommon-lisp

Getting command line arguments in Common Lisp


How can I get the command line arguments in (specifically in GNU, if there are any differences) Common Lisp?


Solution

  • I'm assuming that you are scripting with CLisp. 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")