196 lines
12 KiB
HTML
196 lines
12 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<!-- Created by GNU Texinfo 7.1, https://www.gnu.org/software/texinfo/ -->
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
<!-- This manual documents Guile version 3.0.10.
|
|
|
|
Copyright (C) 1996-1997, 2000-2005, 2009-2023 Free Software Foundation,
|
|
Inc.
|
|
|
|
Copyright (C) 2021 Maxime Devos
|
|
|
|
Copyright (C) 2024 Tomas Volf
|
|
|
|
|
|
Permission is granted to copy, distribute and/or modify this document
|
|
under the terms of the GNU Free Documentation License, Version 1.3 or
|
|
any later version published by the Free Software Foundation; with no
|
|
Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A
|
|
copy of the license is included in the section entitled "GNU Free
|
|
Documentation License." -->
|
|
<title>Runtime Environment (Guile Reference Manual)</title>
|
|
|
|
<meta name="description" content="Runtime Environment (Guile Reference Manual)">
|
|
<meta name="keywords" content="Runtime Environment (Guile Reference Manual)">
|
|
<meta name="resource-type" content="document">
|
|
<meta name="distribution" content="global">
|
|
<meta name="Generator" content=".texi2any-real">
|
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
|
|
<link href="index.html" rel="start" title="Top">
|
|
<link href="Concept-Index.html" rel="index" title="Concept Index">
|
|
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
|
|
<link href="POSIX.html" rel="up" title="POSIX">
|
|
<link href="Processes.html" rel="next" title="Processes">
|
|
<link href="Time.html" rel="prev" title="Time">
|
|
<style type="text/css">
|
|
<!--
|
|
a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
|
|
div.example {margin-left: 3.2em}
|
|
span:hover a.copiable-link {visibility: visible}
|
|
strong.def-name {font-family: monospace; font-weight: bold; font-size: larger}
|
|
-->
|
|
</style>
|
|
<link rel="stylesheet" type="text/css" href="https://www.gnu.org/software/gnulib/manual.css">
|
|
|
|
|
|
</head>
|
|
|
|
<body lang="en">
|
|
<div class="subsection-level-extent" id="Runtime-Environment">
|
|
<div class="nav-panel">
|
|
<p>
|
|
Next: <a href="Processes.html" accesskey="n" rel="next">Processes</a>, Previous: <a href="Time.html" accesskey="p" rel="prev">Time</a>, Up: <a href="POSIX.html" accesskey="u" rel="up"><abbr class="acronym">POSIX</abbr> System Calls and Networking</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<hr>
|
|
<h4 class="subsection" id="Runtime-Environment-1"><span>7.2.6 Runtime Environment<a class="copiable-link" href="#Runtime-Environment-1"> ¶</a></span></h4>
|
|
|
|
<dl class="first-deffn">
|
|
<dt class="deffn" id="index-program_002darguments"><span class="category-def">Scheme Procedure: </span><span><strong class="def-name">program-arguments</strong><a class="copiable-link" href="#index-program_002darguments"> ¶</a></span></dt>
|
|
<dt class="deffnx def-cmd-deffn" id="index-command_002dline"><span class="category-def">Scheme Procedure: </span><span><strong class="def-name">command-line</strong><a class="copiable-link" href="#index-command_002dline"> ¶</a></span></dt>
|
|
<dt class="deffnx def-cmd-deffn" id="index-set_002dprogram_002darguments"><span class="category-def">Scheme Procedure: </span><span><strong class="def-name">set-program-arguments</strong><a class="copiable-link" href="#index-set_002dprogram_002darguments"> ¶</a></span></dt>
|
|
<dt class="deffnx def-cmd-deffn" id="index-scm_005fprogram_005farguments"><span class="category-def">C Function: </span><span><strong class="def-name">scm_program_arguments</strong> <var class="def-var-arguments">()</var><a class="copiable-link" href="#index-scm_005fprogram_005farguments"> ¶</a></span></dt>
|
|
<dt class="deffnx def-cmd-deffn" id="index-scm_005fset_005fprogram_005farguments_005fscm"><span class="category-def">C Function: </span><span><strong class="def-name">scm_set_program_arguments_scm</strong> <var class="def-var-arguments">(lst)</var><a class="copiable-link" href="#index-scm_005fset_005fprogram_005farguments_005fscm"> ¶</a></span></dt>
|
|
<dd><a class="index-entry-id" id="index-command-line"></a>
|
|
<a class="index-entry-id" id="index-program-arguments"></a>
|
|
<p>Get the command line arguments passed to Guile, or set new arguments.
|
|
</p>
|
|
<p>The arguments are a list of strings, the first of which is the invoked
|
|
program name. This is just <code class="code">"guile"</code> (or the executable path)
|
|
when run interactively, or it’s the script name when running a script
|
|
with <samp class="option">-s</samp> (see <a class="pxref" href="Invoking-Guile.html">Invoking Guile</a>).
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example-preformatted">guile -L /my/extra/dir -s foo.scm abc def
|
|
|
|
(program-arguments) ⇒ ("foo.scm" "abc" "def")
|
|
</pre></div>
|
|
|
|
<p><code class="code">set-program-arguments</code> allows a library module or similar to
|
|
modify the arguments, for example to strip options it recognises,
|
|
leaving the rest for the mainline.
|
|
</p>
|
|
<p>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.
|
|
</p>
|
|
<p>The two names <code class="code">program-arguments</code> and <code class="code">command-line</code> are an
|
|
historical accident, they both do exactly the same thing. The name
|
|
<code class="code">scm_set_program_arguments_scm</code> has an extra <code class="code">_scm</code> on the
|
|
end to avoid clashing with the C function below.
|
|
</p></dd></dl>
|
|
|
|
<dl class="first-deftypefn">
|
|
<dt class="deftypefn" id="index-scm_005fset_005fprogram_005farguments"><span class="category-def">C Function: </span><span><code class="def-type">void</code> <strong class="def-name">scm_set_program_arguments</strong> <code class="def-code-arguments">(int argc, char **argv, char *first)</code><a class="copiable-link" href="#index-scm_005fset_005fprogram_005farguments"> ¶</a></span></dt>
|
|
<dd><a class="index-entry-id" id="index-command-line-1"></a>
|
|
<a class="index-entry-id" id="index-program-arguments-1"></a>
|
|
<p>Set the list of command line arguments for <code class="code">program-arguments</code>
|
|
and <code class="code">command-line</code> above.
|
|
</p>
|
|
<p><var class="var">argv</var> is an array of null-terminated strings, as in a C
|
|
<code class="code">main</code> function. <var class="var">argc</var> is the number of strings in
|
|
<var class="var">argv</var>, or if it’s negative then a <code class="code">NULL</code> in <var class="var">argv</var> marks
|
|
its end.
|
|
</p>
|
|
<p><var class="var">first</var> is an extra string put at the start of the arguments, or
|
|
<code class="code">NULL</code> for no such extra. This is a convenient way to pass the
|
|
program name after advancing <var class="var">argv</var> to strip option arguments.
|
|
Eg.
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example-preformatted">{
|
|
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);
|
|
}
|
|
</pre></div>
|
|
|
|
<p>This sort of thing is often done at startup under
|
|
<code class="code">scm_boot_guile</code> with options handled at the C level removed.
|
|
The given strings are all copied, so the C data is not accessed again
|
|
once <code class="code">scm_set_program_arguments</code> returns.
|
|
</p></dd></dl>
|
|
|
|
<dl class="first-deffn">
|
|
<dt class="deffn" id="index-getenv"><span class="category-def">Scheme Procedure: </span><span><strong class="def-name">getenv</strong> <var class="def-var-arguments">name</var><a class="copiable-link" href="#index-getenv"> ¶</a></span></dt>
|
|
<dt class="deffnx def-cmd-deffn" id="index-scm_005fgetenv"><span class="category-def">C Function: </span><span><strong class="def-name">scm_getenv</strong> <var class="def-var-arguments">(name)</var><a class="copiable-link" href="#index-scm_005fgetenv"> ¶</a></span></dt>
|
|
<dd><a class="index-entry-id" id="index-environment-2"></a>
|
|
<p>Looks up the string <var class="var">name</var> in the current environment. The return
|
|
value is <code class="code">#f</code> unless a string of the form <code class="code">NAME=VALUE</code> is
|
|
found, in which case the string <code class="code">VALUE</code> is returned.
|
|
</p></dd></dl>
|
|
|
|
<dl class="first-deffn">
|
|
<dt class="deffn" id="index-setenv"><span class="category-def">Scheme Procedure: </span><span><strong class="def-name">setenv</strong> <var class="def-var-arguments">name value</var><a class="copiable-link" href="#index-setenv"> ¶</a></span></dt>
|
|
<dd><p>Modifies the environment of the current process, which is
|
|
also the default environment inherited by child processes.
|
|
</p>
|
|
<p>If <var class="var">value</var> is <code class="code">#f</code>, then <var class="var">name</var> is removed from the
|
|
environment. Otherwise, the string <var class="var">name</var>=<var class="var">value</var> is added
|
|
to the environment, replacing any existing string with name matching
|
|
<var class="var">name</var>.
|
|
</p>
|
|
<p>The return value is unspecified.
|
|
</p></dd></dl>
|
|
|
|
<dl class="first-deffn">
|
|
<dt class="deffn" id="index-unsetenv"><span class="category-def">Scheme Procedure: </span><span><strong class="def-name">unsetenv</strong> <var class="def-var-arguments">name</var><a class="copiable-link" href="#index-unsetenv"> ¶</a></span></dt>
|
|
<dd><p>Remove variable <var class="var">name</var> from the environment. The
|
|
name can not contain a ‘<samp class="samp">=</samp>’ character.
|
|
</p></dd></dl>
|
|
|
|
<dl class="first-deffn">
|
|
<dt class="deffn" id="index-environ"><span class="category-def">Scheme Procedure: </span><span><strong class="def-name">environ</strong> <var class="def-var-arguments">[env]</var><a class="copiable-link" href="#index-environ"> ¶</a></span></dt>
|
|
<dt class="deffnx def-cmd-deffn" id="index-scm_005fenviron"><span class="category-def">C Function: </span><span><strong class="def-name">scm_environ</strong> <var class="def-var-arguments">(env)</var><a class="copiable-link" href="#index-scm_005fenviron"> ¶</a></span></dt>
|
|
<dd><p>If <var class="var">env</var> 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
|
|
<var class="var">env</var> should be of the form <var class="var">name</var>=<var class="var">value</var> and values of
|
|
<var class="var">name</var> should not be duplicated. If <var class="var">env</var> is supplied
|
|
then the return value is unspecified.
|
|
</p></dd></dl>
|
|
|
|
<dl class="first-deffn">
|
|
<dt class="deffn" id="index-putenv"><span class="category-def">Scheme Procedure: </span><span><strong class="def-name">putenv</strong> <var class="def-var-arguments">str</var><a class="copiable-link" href="#index-putenv"> ¶</a></span></dt>
|
|
<dt class="deffnx def-cmd-deffn" id="index-scm_005fputenv"><span class="category-def">C Function: </span><span><strong class="def-name">scm_putenv</strong> <var class="def-var-arguments">(str)</var><a class="copiable-link" href="#index-scm_005fputenv"> ¶</a></span></dt>
|
|
<dd><p>Modifies the environment of the current process, which is
|
|
also the default environment inherited by child processes.
|
|
</p>
|
|
<p>If <var class="var">str</var> is of the form <code class="code">NAME=VALUE</code> then it will be written
|
|
directly into the environment, replacing any existing environment string
|
|
with
|
|
name matching <code class="code">NAME</code>. If <var class="var">str</var> does not contain an equal
|
|
sign, then any existing string with name matching <var class="var">str</var> will
|
|
be removed.
|
|
</p>
|
|
<p>The return value is unspecified.
|
|
</p></dd></dl>
|
|
|
|
|
|
</div>
|
|
<hr>
|
|
<div class="nav-panel">
|
|
<p>
|
|
Next: <a href="Processes.html">Processes</a>, Previous: <a href="Time.html">Time</a>, Up: <a href="POSIX.html"><abbr class="acronym">POSIX</abbr> System Calls and Networking</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
|
|
|
|
|
|
</body>
|
|
</html>
|