From 7ff0f47e84c4cf6f88d634b63ec46557f1166a0e Mon Sep 17 00:00:00 2001
From: Russ Allbery
Date: Mon, 4 Jun 2007 01:05:51 +0000
Subject: [PATCH] Add test -a/-o and local to shell policy, update wording
Scripts may now assume that /bin/sh supports local (in a limited form)
and, if they use a built-in test, that built-in supports test -a/-o
binary logical operators. Reword to include echo -n as another case
of additional required features. Replace references to POSIX with
SUSv3 and add a link.
git-archimport-id: rra@debian.org--lenny/debian-policy--devel--3.7--patch-2
---
debian/changelog | 3 ++
policy.sgml | 76 +++++++++++++++++++++++++---------------
upgrading-checklist.html | 3 ++
3 files changed, 54 insertions(+), 28 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index 911135c..47c71dc 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,6 +2,9 @@ debian-policy (3.7.3.0) UNRELEASED; urgency=low
* Bug fix: "[PROPOSAL] Document ~ behavior in version numbers", thanks
to Nicolas François and Marc Brockschmidt (Closes: #382612).
+ * Bug fix: "Please add 'local' to list of supra-POSIX features that
+ /bin/sh can be expected to offer". Also add test -a/-o binary logical
+ operators and change references from POSIX to SUSv3 (Closes: #294962)
--
diff --git a/policy.sgml b/policy.sgml
index 4acf402..a17e6a3 100644
--- a/policy.sgml
+++ b/policy.sgml
@@ -5670,7 +5670,7 @@ test -f program-executed-later-in-script || exit 0
/etc/default, which typically will have the same
base name as the init.d script. This extra file
should be sourced by the script when the script runs. It
- must contain only variable settings and comments in POSIX
+ must contain only variable settings and comments in SUSv3
sh format. It may either be a
conffile or a configuration file maintained by
the package maintainer scripts. See [
@@ -6731,34 +6731,54 @@ strip --strip-unneeded your-lib
]
- The standard shell interpreter /bin/sh can be a
- symbolic link to any POSIX compatible shell, if echo
- -n does not generate a newline.
- Debian policy specifies POSIX behavior for
- /bin/sh, but echo -n has widespread
- use in the Linux community (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.
+ Scripts may assume that /bin/sh implements the
+ SUSv3 Shell Command Language
+ Single UNIX Specification, version 3, which is also IEEE
+ 1003.1-2004 (POSIX), and is available on the World Wide Web
+ from after free
+ registration.
+ plus the following additional features not mandated by
+ SUSv3:
+ These features are in widespread use in the Linux community
+ and are implemented in all of bash, dash, and ksh, the most
+ common shells users may wish to use as /bin/sh.
- Thus, shell scripts specifying /bin/sh as
- interpreter must only use POSIX features. If a script
- requires non-POSIX features from the shell interpreter, 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
+
+ - echo -n, if implemented as a shell built-in,
+ must not generate a newline.
+ - test, if implemented as a shell built-in, must
+ support -a and -o as binary logical
+ operators.
+ - local to create a scoped variable must be
+ supported; however, local may or may not preserve
+ the variable value from an outer scope and may or may not
+ support arguments more complex than simple variables. Only
+ uses such as:
+
+fname () {
+ local a
+ a=''
+ # ... use a ...
+}
+
+ must be supported.
+
+
+ If a shell script requires non-SUSv3 features from the shell
+ interpreter other than those listed above, 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 SUSv3 features plus the
+ above set when possible so that it may use /bin/sh
+ as its interpreter. If your script works with dash
+ (originally called ash), it probably complies with
+ the above requirements, but if you are in doubt, use
/bin/bash.
diff --git a/upgrading-checklist.html b/upgrading-checklist.html
index 4fe8c71..1748b49 100644
--- a/upgrading-checklist.html
+++ b/upgrading-checklist.html
@@ -56,6 +56,9 @@ picking your way through this list.
3.7.3.0 unreleased
* Package version numbers may contain tildes, which sort before
anything, even the end of a part. [5.6.12]
+ * Scripts may assume that /bin/sh supports local (at a basic level)
+ and that its test builtin (if any) supports -a and -o binary
+ logical operators. [10.4]
3.7.2.2 Oct 2006
* Maintainer scripts must not be world writeable (up from a
should to a must) [6.1]
--
2.39.5