Next: , Previous: , Up: The language   [Contents][Index]


5.35 Command Line Options

As noted earlier any unused command line arguments are made available to scripts through the command-line-args variable (see Invocation).

Variable: command-line-args

The list of unused command line arguments, in their original order.

The get-command-line-option function may be used to scan this list of arguments. The rep.system module exports this function.

Function: get-command-line-option option #!optional requires-arg

Returns t if option was specified on the command line (option is typically a phrase beginning with ‘--’).

If requires-arg is true, the option requires a parameter, the value of which is returned. If a parameter isn’t supplied an error is signalled.

(setq command-line-args '("--foo" "bar"))
    ⇒ ("--foo" "bar")
(get-command-line-option "--foo" t)
    ⇒ "bar"
command-line-args
    ⇒ ()

(setq command-line-args '("--foo=bar"))
    ⇒ ("--foo=bar")
(get-command-line-option "--foo" t)
    ⇒ "bar"
command-line-args
    ⇒ ()