1. Module (chicken process-context)
    1. Information about the program's invocation
      1. argc+argv
      2. argv
      3. command-line-arguments
      4. executable-pathname
      5. program-name
    2. Access to environment variables
      1. get-environment-variables
      2. get-environment-variable
      3. set-environment-variable!
      4. unset-environment-variable!
    3. Process filesystem context
      1. change-directory
      2. current-directory

Module (chicken process-context)

This module provides access to the current process context.

Information about the program's invocation

argc+argv

[procedure] (argc+argv)

Returns two values: an integer and a foreign-pointer object representing the argc and argv arguments passed to the current process. See also argv below.

argv

[procedure] (argv)

Return a list of all supplied command-line arguments. The first item in the list is a string containing the name of the executing program. The other items are the arguments passed to the application. It depends on the host-shell whether arguments are expanded ('globbed') or not.

NOTE: This is the "raw" unprocessed argument list, including runtime options (starting with -:) which are consumed by the runtime library.

command-line-arguments

[parameter] (command-line-arguments)

Contains the list of arguments passed to this program.

This excludes the name of the program, as well as any runtime options (options starting with -:) up until the first empty runtime option (just "-:") or non-runtime option, whichever comes first.

In other words, this method returns every option after the first list of unbroken runtime options, which are all skipped. If an empty runtime option is present, that is the last of this list of unbroken runtime options and everything after it is returned by this method. If a non-runtime option is present, that also breaks up the runtime options and this method returns that and every following option.

executable-pathname

[procedure] (executable-pathname)

Returns a full pathname of the currently-running executable, or #f if it couldn't be determined. When evaluating code in the interpreter, this will be a path to csi.

program-name

[parameter] (program-name)

The name of the currently executing program. This is equivalent to (car (argv)) for compiled programs or the filename following the -script option in interpreted scripts.

Access to environment variables

get-environment-variables

[procedure] (get-environment-variables)

Returns a association list of the environment variables and their current values (see also SRFI-98).

get-environment-variable

[procedure] (get-environment-variable STRING)

Returns the value of the environment variable STRING or #f if that variable is not defined. See also SRFI-98.

set-environment-variable!

[procedure] (set-environment-variable! VARIABLE VALUE)

Sets the environment variable named VARIABLE to VALUE. Both arguments should be strings. If the variable is not defined in the environment, a new definition is created.

unset-environment-variable!

[procedure] (unset-environment-variable! VARIABLE)

Removes the definition of the environment variable VARIABLE from the environment of the current process. If the variable is not defined, nothing happens.

Process filesystem context

change-directory

[procedure] (change-directory NAME)
[procedure] (set! (current-directory) NAME)

Changes the current working directory to NAME.

current-directory

[procedure] (current-directory)

Returns the name of the current working directory.


Previous: Module (chicken process signal)

Next: Module (chicken process-context posix)