Next: , Up: UNIX Interface   [Contents][Index]


6.1 Reading the Command Line

The shell parses the command line with which Lisp is invoked, and passes a data structure containing the parsed information to Lisp. This information is then extracted from that data structure and put into a set of Lisp data structures.

Variable: extensions:*command-line-strings*
Variable: extensions:*command-line-utility-name*
Variable: extensions:*command-line-words*
Variable: extensions:*command-line-switches*

The value of *command-line-words* is a list of strings that make up the command line, one word per string. The first word on the command line, i.e. the name of the program invoked (usually lisp) is stored in *command-line-utility-name*. The value of *command-line-switches* is a list of command-line-switch structures, with a structure for each word on the command line starting with a hyphen. All the command line words between the program name and the first switch are stored in *command-line-words*.

The following functions may be used to examine command-line-switch structures.

Function: extensions:cmd-switch-name switch

Returns the name of the switch, less the preceding hyphen and trailing equal sign (if any).

Function: extensions:cmd-switch-value switch

Returns the value designated using an embedded equal sign, if any. If the switch has no equal sign, then this is null.

Function: extensions:cmd-switch-words switch

Returns a list of the words between this switch and the next switch or the end of the command line.

Function: extensions:cmd-switch-arg switch

Returns the first non-null value from cmd-switch-value, the first element in cmd-switch-words, or the first word in command-line-words.

Function: extensions:get-command-line-switch sname

This function takes the name of a switch as a string and returns the value of the switch given on the command line. If no value was specified, then any following words are returned. If there are no following words, then t is returned. If the switch was not specified, then nil is returned.

Macro: extensions:defswitch name &optional function

This macro causes function to be called when the switch name appears in the command line. Name is a simple-string that does not begin with a hyphen (unless the switch name really does begin with one.)

If function is not supplied, then the switch is parsed into command-line-switches, but otherwise ignored. This suppresses the undefined switch warning which would otherwise take place. The warning can also be globally suppressed by complain-about-illegal-switches.


Next: Useful Variables, Up: UNIX Interface   [Contents][Index]