Chapter 10. Files
80
10.3 Shared libraries
This section has moved to `Shared libraries' on page
53
.
10.4 Scripts
All command scripts, including the package maintainer scripts inside the package and used
by
dpkg
, should have a
#!
line naming the shell to be used to interpret them.
In the case of Perl scripts this should be
#!/usr/bin/perl
.
Shell scripts (
sh
and
bash
) should almost certainly start with
set e
so that errors are de
tected. Every script should use
set e
or check the exit status of every command.
The standard shell interpreter
/bin/sh
can be a symbolic link to any POSIX compatible shell,
if
echo n
does not generate a newline.
4
Thus, shell scripts specifying
/bin/sh
as interpreter
should only use POSIX features. If a script requires non POSIX features from the shell inter
preter, the appropriate shell must be specified in the first line of the script (e.g.,
#!/bin/bash
)
and the package must depend on the package providing the shell (unless the shell package is
marked Essential , as in the case of
bash
).
You may wish to restrict your script to POSIX features when possible so that it may use
/bin
/sh
as its interpreter. If your script works with
dash
(originally called
ash
), it's probably
POSIX compliant, but if you are in doubt, use
/bin/bash
.
Perl scripts should check for errors when making any system calls, including
open
,
print
,
close
,
rename
and
system
.
csh
and
tcsh
should be avoided as scripting languages. See Csh Programming Considered
Harmful, one of the
comp.unix.*
FAQs, which can be found at
http://www.faqs.org/
faqs/unix faq/shell/csh whynot/
. If an upstream package comes with
csh
scripts
then you must make sure that they start with
#!/bin/csh
and make your package depend
on the
c shell
virtual package.
Any scripts which create files in world writeable directories (e.g., in
/tmp
) must use a mecha
nism which will fail if a file with the same name already exists.
The Debian base system provides the
tempfile
and
mktemp
utilities for use by scripts for
this purpose.
10.5 Symbolic links
In general, symbolic links within a top level directory should be relative, and symbolic links
pointing from one top level directory into another should be absolute. (A top level directory
4
Debian policy specifies POSIX behavior for
/bin/sh
, but
echo n
has widespread use in the Linux com
munity (in particular including this policy, the Linux kernel source, many Debian scripts, etc.). This
echo n
mechanism is valid but not required under POSIX, hence this explicit addition. Also, rumour has it that this shall
be mandated under the LSB anyway.
footer
Our partners:
PHP: Hypertext Preprocessor Best Web Hosting
Java Web Hosting
Inexpensive Web Hosting
Jsp Web Hosting
Cheapest Web Hosting
Jsp Hosting
Cheap Hosting
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved