command-line - retrieve the program's command line

LIBRARY

(import (rnrs))                     ;R6RS
(import (rnrs programs))            ;R6RS
(import (scheme process-context))   ;R7RS

SYNOPSIS

(command-line)

DESCRIPTION

Returns the command line passed to the process as a list of strings. The first element is an implementation-specific name for the running top-level program. The remaining elements are command-line arguments according to the operating system's conventions.
R7RS
It is an error to mutate any of these strings.

IMPLEMENTATION NOTES

Larceny
Larceny uses "larceny" as the first element of the list.

RETURN VALUES

Returns a single value which is a list of strings.

EXAMPLES

;; cmd.sps
#!/usr/bin/env scheme-script
(import (rnrs))
(write (command-line))
(newline)

;; When invoked from the shell:
$ ./cmd.sps Hello World
("./cmd.sps" "Hello" "World")

APPLICATION USAGE

This procedure is used in programs that are invoked from the command line or that can be customized with a command line argument. Programs meant to be invoked from the shell can use a command line parser like SRFI-37.

COMPATIBILITY

The first string in the list is unreliable. Many implementations use the name of the program file or copy the string received from the operating system, but there exist situations where that fails, such as when execve(2) is used with a NULL or zero-length argv.

ERRORS

This procedure can raise exceptions with the following condition types:
&assertion (R6RS)
The wrong number of arguments was passed.
R7RS
The assertions described above are errors. Implementations may signal an error, extend the procedure's domain of definition to include such arguments, or fail catastrophically.

SEE ALSO

STANDARDS

R6RS, R7RS, SRFI-193

HISTORY

This procedure is new to R6RS and to R7RS. Early Scheme systems running on MacLISP had access to (status jcl) that returned the job command line, or the equivalent depending on which system it was running on.

AUTHORS

This page is part of the scheme-manpages project. It includes materials from the RnRS documents. More information can be found at https://github.com/schemedoc/manpages/.


Markup created by unroff 1.0sc,    March 04, 2023.