www.delorie.com/gnu/docs/gcl/gcl-si_11.html   search  
 
Buy GNU books!


Untitled Document

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.1 Command Line

The variable si::*command-args* is set to the list of strings passed in when gcl is invoked.

Various flags are understood.

-eval
Call read and then eval on the command argument following -eval
-load
Load the file whose pathname is specified after -load.
-f
Replace si::*command-args* by the the list starting after -f. Open the file following -f for input, skip the first line, and then read and eval the rest of the forms in the file. This can be used as with the shells to write small shell programs:
 
#!/usr/local/bin/gcl.exe -f
(format t "hello world ~a~%" (nth 1 si::*command-args*))
The value si::*command-args* will have the appropriate value. Thus if the above 2 line file is made executable and called `foo' then
 
tutorial% foo billy
hello world billy
NOTE: On many systems (eg SunOs) the first line of an executable script file such as:
 
#!/usr/local/bin/gcl.exe -f
only reads the first 32 characters! So if your pathname where the executable together with the '-f' amount to more than 32 characters the file will not be recognized. Also the executable must be the actual large binary file, [or a link to it], and not just a /bin/sh script. In latter case the /bin/sh interpreter would get invoked on the file.

Alternately one could invoke the file `foo' without making it executable:
 
tutorial% gcl -f foo "from bill"
hello world from bill

Finally perhaps the best way (why do we save the best for last.. I guess because we only figure it out after all the others..) The following file `myhello' has 4 lines:
 
#!/bin/sh
#| Lisp will skip the next 2 lines on reading
exec gcl   -f "$0" $
|#
(format t "hello world ~a~%" (nth 1 si::*command-args*))

 
marie% chmod a+x myhello
marie% myhello bill
hello world bill

The advantage of this method is that `gcl' can itself be a shell script, which sets up environment and so on. Also the normal path will be searched to find `gcl' The disadvantage is that this would cause 2 invocations of `sh' and one invocation of `gcl'. The plan using `gcl.exe' bypasses the `sh' entirely. Inded invoking `gcl.exe' to print `hello world' is faster on most systems than a similar `csh' or `bash' script, but slightly slower than the old `sh'.

-batch
Do not enter the command print loop. Useful if the other command line arguments do something. Do not print the License and acknowledgement information. Note if your program does print any License information, it must print the GCL header information also.
-dir
Directory where the executable binary that is running is located. Needed by save and friends. This gets set as si::*system-directory*
-libdir
 
   -libdir `/d/wfs/gcl-2.0/'
would mean that the files like gcl-tk/tk.o would be found by concatting the path to the libdir path, ie in
 
`/d/wfs/gcl-2.0/gcl-tk/tk.o'
-compile
Invoke the compiler on the filename following -compile. Other flags affect compilation.
-o-file
If nil follows -o-file then do not produce an .o file.
-c-file
If -c-file is specified, leave the intermediate .c file there.
-h-file
If -h-file is specified, leave the intermediate .h file there.
-data-file
If -data-file is specified, leave the intermediate .data file there.
-system-p
If -system-p is specified then invoke compile-file with the :system-p t keyword argument, meaning that the C init function will bear a name based on the name of the file, so that it may be invoked by name by C code.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster   donations   bookstore     delorie software   privacy  
  Copyright © 2003   by The Free Software Foundation     Updated Jun 2003