~ chicken-core (chicken-5) /manual/Module (chicken process-context)
Trap1[[tags: manual]]2[[toc:]]34== Module (chicken process-context)56This module provides access to the current process context.78* New in CHICKEN 5.4.0: Errors caused by underlying C calls that9 change errno will produce a condition object with an {{errno}}10 property, which can be accessed with11 {{(get-condition-property <the-condition-object> 'exn 'errno)}}.1213=== Information about the program's invocation1415==== argc+argv1617<procedure>(argc+argv)</procedure>1819Returns two values: an integer and a foreign-pointer object20representing the {{argc}} and {{argv}} arguments passed to the current21process. See also {{argv}} below.2223==== argv2425<procedure>(argv)</procedure>2627Return a list of all supplied command-line arguments. The first item in28the list is a string containing the name of the executing program. The29other items are the arguments passed to the application. It depends on30the host-shell whether arguments are expanded ('globbed') or not.3132NOTE: This is the "raw" unprocessed argument list, including runtime33options (starting with {{-:}}) which are consumed by the runtime34library.3536==== command-line-arguments3738<parameter>(command-line-arguments)</parameter>3940Contains the list of arguments passed to this program.4142This ''excludes'' the name of the program, as well as any runtime43options (options starting with {{-:}}) up until the first empty44runtime option (just {{"-:"}}) or non-runtime option, whichever45comes first.4647In other words, this method returns every option ''after'' the first48list of unbroken runtime options, which are all skipped. If an empty49runtime option is present, that is the last of this list of unbroken50runtime options and everything after it is returned by this method.51If a non-runtime option is present, that also breaks up the runtime52options and this method returns that and every following option.5354==== executable-pathname5556<procedure>(executable-pathname)</procedure>5758Returns a full pathname of the currently-running executable, or {{#f}}59if it couldn't be determined. When evaluating code in the interpreter,60this will be a path to {{csi}}.6162==== program-name6364<parameter>(program-name)</parameter>6566The name of the currently executing program. This is equivalent to67{{(car (argv))}} for compiled programs or the filename following the68{{-script}} option in interpreted scripts.697071=== Access to environment variables7273==== get-environment-variables7475<procedure>(get-environment-variables)</procedure>7677Returns a association list of the environment variables and their78current values (see also [[http://srfi.schemers.org/srfi-98/|SRFI-98]]).7980==== get-environment-variable8182<procedure>(get-environment-variable STRING)</procedure><br>8384Returns the value of the environment variable {{STRING}} or85{{#f}} if that variable is not defined. See also [[http://srfi.schemers.org/srfi-98/|SRFI-98]].8687==== set-environment-variable!8889<procedure>(set-environment-variable! VARIABLE VALUE)</procedure>9091Sets the environment variable named {{VARIABLE}} to92{{VALUE}}. Both arguments should be strings. If the variable is93not defined in the environment, a new definition is created.9495==== unset-environment-variable!9697<procedure>(unset-environment-variable! VARIABLE)</procedure>9899Removes the definition of the environment variable {{VARIABLE}} from100the environment of the current process. If the variable is not defined,101nothing happens.102103104=== Process filesystem context105106==== change-directory107108<procedure>(change-directory NAME)</procedure>109<procedure>(set! (current-directory) NAME)</procedure>110111Changes the current working directory to {{NAME}}.112113==== current-directory114115<procedure>(current-directory)</procedure>116117Returns the name of the current working directory.118119---120Previous: [[Module (chicken process signal)]]121122Next: [[Module (chicken process-context posix)]]