From: Parth Malwankar
Subject: cmd line args for clisp built executable
Date:
Message-ID: <op.udvrg5eny4b379@localhost>
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
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 ············@yahoo.com
Selbst in die Unterwelt dringt durch Spalten Licht
EN:SiS(9)
From: Parth Malwankar
Subject: Re: cmd line args for clisp built executable
Date:
Message-ID: <op.udxktmh1y4b379@localhost>
On Sun, 06 Jul 2008 23:21:47 +0530, Joost Kremers <············@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
From: Parth Malwankar
Subject: Re: cmd line args for clisp built executable
Date:
Message-ID: <op.udvwr0jfy4b379@localhost>
On Sun, 06 Jul 2008 22:43:43 +0530, Parth Malwankar
<·················@parth.malwankar> wrote:
> 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.
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