Warning: This is the manual of the legacy Guile 2.0 series. You may want to read the manual of the current stable series instead.
Get the command line arguments passed to Guile, or set new arguments.
The arguments are a list of strings, the first of which is the invoked
program name. This is just "guile"
(or the executable path)
when run interactively, or it’s the script name when running a script
with -s (see Invoking Guile).
guile -L /my/extra/dir -s foo.scm abc def (program-arguments) ⇒ ("foo.scm" "abc" "def")
set-program-arguments
allows a library module or similar to
modify the arguments, for example to strip options it recognises,
leaving the rest for the mainline.
The argument list is held in a fluid, which means it’s separate for each thread. Neither the list nor the strings within it are copied at any point and normally should not be mutated.
The two names program-arguments
and command-line
are an
historical accident, they both do exactly the same thing. The name
scm_set_program_arguments_scm
has an extra _scm
on the
end to avoid clashing with the C function below.
Set the list of command line arguments for program-arguments
and command-line
above.
argv is an array of null-terminated strings, as in a C
main
function. argc is the number of strings in
argv, or if it’s negative then a NULL
in argv marks
its end.
first is an extra string put at the start of the arguments, or
NULL
for no such extra. This is a convenient way to pass the
program name after advancing argv to strip option arguments.
Eg.
{ char *progname = argv[0]; for (argv++; argv[0] != NULL && argv[0][0] == '-'; argv++) { /* munch option ... */ } /* remaining args for scheme level use */ scm_set_program_arguments (-1, argv, progname); }
This sort of thing is often done at startup under
scm_boot_guile
with options handled at the C level removed.
The given strings are all copied, so the C data is not accessed again
once scm_set_program_arguments
returns.
Looks up the string name in the current environment. The return
value is #f
unless a string of the form NAME=VALUE
is
found, in which case the string VALUE
is returned.
Modifies the environment of the current process, which is also the default environment inherited by child processes.
If value is #f
, then name is removed from the
environment. Otherwise, the string name=value is added
to the environment, replacing any existing string with name matching
name.
The return value is unspecified.
Remove variable name from the environment. The name can not contain a ‘=’ character.
If env is omitted, return the current environment (in the Unix sense) as a list of strings. Otherwise set the current environment, which is also the default environment for child processes, to the supplied list of strings. Each member of env should be of the form name=value and values of name should not be duplicated. If env is supplied then the return value is unspecified.
Modifies the environment of the current process, which is also the default environment inherited by child processes.
If str is of the form NAME=VALUE
then it will be written
directly into the environment, replacing any existing environment string
with
name matching NAME
. If str does not contain an equal
sign, then any existing string with name matching str will
be removed.
The return value is unspecified.