109 lines
4.9 KiB
HTML
109 lines
4.9 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>The Top of a Script File (Guile Reference Manual)</title>
|
||
|
|
||
|
<meta name="description" content="The Top of a Script File (Guile Reference Manual)">
|
||
|
<meta name="keywords" content="The Top of a Script File (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="Guile-Scripting.html" rel="up" title="Guile Scripting">
|
||
|
<link href="The-Meta-Switch.html" rel="next" title="The Meta Switch">
|
||
|
<style type="text/css">
|
||
|
<!--
|
||
|
a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
|
||
|
span:hover a.copiable-link {visibility: visible}
|
||
|
ul.mark-bullet {list-style-type: disc}
|
||
|
-->
|
||
|
</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="The-Top-of-a-Script-File">
|
||
|
<div class="nav-panel">
|
||
|
<p>
|
||
|
Next: <a href="The-Meta-Switch.html" accesskey="n" rel="next">The Meta Switch</a>, Up: <a href="Guile-Scripting.html" accesskey="u" rel="up">Guile Scripting</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="The-Top-of-a-Script-File-1"><span>4.3.1 The Top of a Script File<a class="copiable-link" href="#The-Top-of-a-Script-File-1"> ¶</a></span></h4>
|
||
|
|
||
|
<p>The first line of a Guile script must tell the operating system to use
|
||
|
Guile to evaluate the script, and then tell Guile how to go about doing
|
||
|
that. Here is the simplest case:
|
||
|
</p>
|
||
|
<ul class="itemize mark-bullet">
|
||
|
<li>The first two characters of the file must be ‘<samp class="samp">#!</samp>’.
|
||
|
|
||
|
<p>The operating system interprets this to mean that the rest of the line
|
||
|
is the name of an executable that can interpret the script. Guile,
|
||
|
however, interprets these characters as the beginning of a multi-line
|
||
|
comment, terminated by the characters ‘<samp class="samp">!#</samp>’ on a line by themselves.
|
||
|
(This is an extension to the syntax described in R5RS, added to support
|
||
|
shell scripts.)
|
||
|
</p>
|
||
|
</li><li>Immediately after those two characters must come the full pathname to
|
||
|
the Guile interpreter. On most systems, this would be
|
||
|
‘<samp class="samp">/usr/local/bin/guile</samp>’.
|
||
|
|
||
|
</li><li>Then must come a space, followed by a command-line argument to pass to
|
||
|
Guile; this should be ‘<samp class="samp">-s</samp>’. This switch tells Guile to run a
|
||
|
script, instead of soliciting the user for input from the terminal.
|
||
|
There are more elaborate things one can do here; see <a class="ref" href="The-Meta-Switch.html">The Meta Switch</a>.
|
||
|
|
||
|
</li><li>Follow this with a newline.
|
||
|
|
||
|
</li><li>The second line of the script should contain only the characters
|
||
|
‘<samp class="samp">!#</samp>’ — just like the top of the file, but reversed. The
|
||
|
operating system never reads this far, but Guile treats this as the end
|
||
|
of the comment begun on the first line by the ‘<samp class="samp">#!</samp>’ characters.
|
||
|
|
||
|
</li><li>If this source code file is not ASCII or ISO-8859-1 encoded, a coding
|
||
|
declaration such as <code class="code">coding: utf-8</code> should appear in a comment
|
||
|
somewhere in the first five lines of the file: see <a class="ref" href="Character-Encoding-of-Source-Files.html">Character Encoding of Source Files</a>.
|
||
|
|
||
|
</li><li>The rest of the file should be a Scheme program.
|
||
|
|
||
|
</li></ul>
|
||
|
|
||
|
<p>Guile reads the program, evaluating expressions in the order that they
|
||
|
appear. Upon reaching the end of the file, Guile exits.
|
||
|
</p>
|
||
|
</div>
|
||
|
<hr>
|
||
|
<div class="nav-panel">
|
||
|
<p>
|
||
|
Next: <a href="The-Meta-Switch.html">The Meta Switch</a>, Up: <a href="Guile-Scripting.html">Guile Scripting</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>
|