Search code examples
lispcommon-lispclisp

Read terminal argument and pass the function in lisp?


(defun gppinterpreter (filename)
    (setq fileContent (read-a-file filename))
    (write filecontent)
)
(gppinterpreter filename)

I compile this file in ubuntu

clisp example.lisp

I want to get the filename parameter directly from the terminal such as >> clisp example.lisp filename

but this command not working. How can I get filename parameter in gppinterpreter from terminal


Solution

  • In Clisp, the program arguments are given in the variable EXT:*ARGS*..

    https://clisp.sourceforge.io/impnotes/clisp.html

    Before it is loaded, the variable EXT:ARGS is bound to a LIST of STRINGs, representing the arguments given to the Lisp script (i.e., $1 in /bin/sh becomes (FIRST EXT:ARGS) etc).

    So I think you want to use (second EXT:*ARGS*)