79 lines
4.3 KiB
HTML
79 lines
4.3 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<html>
|
|
<head>
|
|
<meta content="text/html; charset=UTF-8" http-equiv="content-type">
|
|
<title>shell script conventions</title>
|
|
<meta content="$Author: maroy $" name="author">
|
|
</head>
|
|
<body>
|
|
<h1>Preface</h1>
|
|
This document is part of the <a href="http://livesupport.campware.org/">LiveSupport</a>
|
|
project, Copyright © 2004 <a href="http://www.mdlf.org/">Media
|
|
Development Loan Fund</a>, under the GNU <a
|
|
href="http://www.gnu.org/licenses/gpl.html">GPL</a>.<br>
|
|
<ul>
|
|
<li>Author: $Author: maroy $</li>
|
|
<li>Version: $Revision: 1.2 $</li>
|
|
<li>Location: $Source:
|
|
/home/cvs/livesupport/doc/developmentEnvironment/shellScriptConventions.html,v
|
|
$</li>
|
|
</ul>
|
|
<h1>Scope</h1>
|
|
This document describes the shell script file conventions for the
|
|
LiveSupport
|
|
project. See also the generic description of the <a
|
|
href="fileConventions.html">file
|
|
conventions</a> in the LiveSupport
|
|
project.<br>
|
|
<h1>Introduction</h1>
|
|
Shell scripts are text-based executable shell command files. As text
|
|
based files, they should adhere to the <a
|
|
href="fileConventions.html#textConventions">generic text-based
|
|
conventions</a>.<br>
|
|
<h1>Naming</h1>
|
|
Shell script files are named by the following rules:<br>
|
|
<ul>
|
|
<li>there are no spaces in the file name</li>
|
|
<li>the file name begins with a lower case letter</li>
|
|
<li>for file names containing multiple words, each additional word
|
|
begins with a capital letter</li>
|
|
<li>the extension of the file is <code>.sh</code><br>
|
|
</li>
|
|
</ul>
|
|
For example, a file with a single-word name may be named like: <code>single.sh</code>,
|
|
whereas a file with multiple word name would be like: <code>multipleWordNameFile.sh</code>.<br>
|
|
<h1>Structure</h1>
|
|
Shell script files are partitioned by using the following 80 column
|
|
wide partitioning comment:<br>
|
|
<pre>#-------------------------------------------------------------------------------<br># This is the title of the partition<br>#-------------------------------------------------------------------------------<br></pre>
|
|
The file has the
|
|
following mandatory structure:<br>
|
|
<ul>
|
|
<li>Reference to the shell<br>
|
|
</li>
|
|
<li>Header</li>
|
|
<li>Additional sections+</li>
|
|
</ul>
|
|
<h2>Reference to the shell<br>
|
|
</h2>
|
|
This is the mandatory reference to the shell executable each script has
|
|
to begin with:<br>
|
|
<pre><code>#!/bin/sh</code><br></pre>
|
|
<h2>Header</h2>
|
|
The header holds all information mandated by the <a
|
|
href="fileConventions.html#header">generic guidelines</a>, but
|
|
starting with the shell comment character <code>#</code>. Note the 80
|
|
column wide partitioning delimiter enclosing the header.<br>
|
|
<pre>#-------------------------------------------------------------------------------<br># Copyright (c) 2004 Media Development Loan Fund<br>#<br># This file is part of the LiveSupport project.<br># http://livesupport.campware.org/<br># To report bugs, send an e-mail to bugs@campware.org<br>#<br># LiveSupport is free software; you can redistribute it and/or modify<br># it under the terms of the GNU General Public License as published by<br># the Free Software Foundation; either version 2 of the License, or<br># (at your option) any later version.<br>#<br># LiveSupport is distributed in the hope that it will be useful,<br># but WITHOUT ANY WARRANTY; without even the implied warranty of<br># MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the<br># GNU General Public License for more details.<br>#<br># You should have received a copy of the GNU General Public License<br># along with LiveSupport; if not, write to the Free Software<br># Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA<br>#<br>#<br># Author : $Author: maroy $<br># Version : $Revision: 1.2 $<br># Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/doc/developmentEnvironment/shellScriptConventions.html,v $<br>#-------------------------------------------------------------------------------<br></pre>
|
|
<h2>Additional sections</h2>
|
|
Additional sections contain the executing code of the script. Bigger
|
|
parts of the script may be partitioned by the partitioning commend seen
|
|
above.<br>
|
|
<h1>Template</h1>
|
|
See a generic <a href="templates/shellScriptTemplate.sh">template
|
|
for shell scripts</a>. You may freely copy this
|
|
template when starting to create a new document.<br>
|
|
<br>
|
|
</body>
|
|
</html>
|