Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

cmd line args for clisp built executable

7 views
Skip to first unread message

Parth Malwankar

unread,
Jul 6, 2008, 1:13:43 PM7/6/08
to
Hello,

I am trying to create an executable using clisp.
I am unable to figure out how to get the executable
to accept command line args without the '--' delimiter.
The options passed are first processed by clisp and only
the ones delimted by -- are passed to the init-function.

The scaled down example:

[parth:~/code/bld/src]% cat tmp-exe.lisp
(ext:saveinitmem "tmp.out"
:executable t
:quiet t
:norc t
:script t
:init-function (lambda ()
(unwind-protect
(progn
(format t "args: ~A~%" *args*)
(ext:quit)))))

[parth:~/code/bld/src]% ./tmp.out -a
GNU CLISP: invalid argument: '-a'
GNU CLISP: use '-h' for help

[parth:~/code/bld/src]% ./tmp.out -x
args: NIL

[parth:~/code/bld/src]% ./tmp.out -- -h
args: (-h)
[parth:~/code/bld/src]%

Would very much appreciate any pointers on how / if
this can be accomplished with clisp.

Thanks.
--
Parth Malwankar

Joost Kremers

unread,
Jul 6, 2008, 1:51:47 PM7/6/08
to
Parth Malwankar wrote:
> Would very much appreciate any pointers on how / if
> this can be accomplished with clisp.

not really a solution, but a work-around: create a small shell script that
you call instead of the executable:

#!/bin/bash
exec tmp.out -- "$@"


--
Joost Kremers joostk...@yahoo.com
Selbst in die Unterwelt dringt durch Spalten Licht
EN:SiS(9)

Parth Malwankar

unread,
Jul 6, 2008, 3:08:14 PM7/6/08
to

Played around with the options some more. I didn't fully understand
the :script option earlier. This seems to do what I want.

[parth:~/code/bld/src]% cat tmp-exe-script-nil.lisp
(ext:saveinitmem "tmp-script-nil.out"


:executable t
:quiet t
:norc t

:script nil ;------------ what we want


:init-function (lambda ()
(unwind-protect
(progn
(format t "args: ~A~%" *args*)
(ext:quit)))))

[parth:~/code/bld/src]% ./tmp-script-t.out a
*** - LOAD: A file with name a does not exist

[parth:~/code/bld/src]% ./tmp-script-nil.out a
args: (a)

tmp-script-nil.out seems to work fine above.

The only nit seems to be that if an option is that same as a
existing clisp option, it gets picked up by clisp first.

[parth:~/code/bld/src]% ./tmp-script-t.out -h
GNU CLISP (http://clisp.cons.org/) is an ANSI Common Lisp.
Usage: ./tmp-script-t.out [options] [lispfile [argument ...]]
........ help msg snipped ............
Default action is an interactive read-eval-print loop.

[parth:~/code/bld/src]% ./tmp-script-nil.out -h
GNU CLISP (http://clisp.cons.org/) is an ANSI Common Lisp.
.......... help msg snipped ..........
Default action is an interactive read-eval-print loop.

Any ideas if this can be prevented? Thanks.

--
Parth Malwankar

Parth Malwankar

unread,
Jul 7, 2008, 12:45:12 PM7/7/08
to
On Sun, 06 Jul 2008 23:21:47 +0530, Joost Kremers <joostk...@yahoo.com>
wrote:

> Parth Malwankar wrote:
>> Would very much appreciate any pointers on how / if
>> this can be accomplished with clisp.
>
> not really a solution, but a work-around: create a small shell script
> that
> you call instead of the executable:
>
> #!/bin/bash
> exec tmp.out -- "$@"
>
>

Thanks Joost. Thats probably the best way to do it.

I checked on the clisp-list for this. The idea behind
this is to keep the clisp prompt accessible from any
executable (which sounds reasonable to me).

http://article.gmane.org/gmane.lisp.clisp.general/12297

--
Parth Malwankar

0 new messages