[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Proposed new POSIX sh policy



Michal Politowski <mpol@charybda.icm.edu.pl> writes:
> On Sun,  5 Nov 2006 19:41:40 -0800, Russ Allbery wrote:
> [...]
>> +	    <item><tt>local</tt> to create a scoped variable must be
>> +	      supported</item>

> Underspecified. local in dash and bash behave differently. In dash the
> variable value from outer scope is retained, in bash it is not.
> Bugs caused by this do happen: see eg. #381237

> Also local in dash is documented to be only allowed at the beginning of
> a function, and take only variable names, not assignments, as arguments,
> though in practice it seems this is not enforced and more bash-like
> behaviour works.

Here's a revised patch.  Does this resolve that concern?

--- orig/policy.sgml
+++ mod/policy.sgml
@@ -6727,33 +6727,45 @@
 
 	<p>
 	  The standard shell interpreter <file>/bin/sh</file> can be a
-	  symbolic link to any POSIX compatible shell, if <tt>echo
-	  -n</tt> does not generate a newline.<footnote>
-	      Debian policy specifies POSIX behavior for
-	      <file>/bin/sh</file>, but <tt>echo -n</tt> has widespread
-	      use in the Linux community (in particular including this
-	      policy, the Linux kernel source, many Debian scripts,
-	      etc.).  This <tt>echo -n</tt> 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.
-	  </footnote>
+	  symbolic link to any POSIX compatible shell provided that it
+	  supports the following additional features not mandated by
+	  POSIX:
+	  <list>
+	    <item><tt>echo -n</tt> must not generate a newline<footnote>
+		Debian policy specifies POSIX behavior for
+		<file>/bin/sh</file>, but <tt>echo -n</tt> has widespread
+		use in the Linux community (in particular including this
+		policy, the Linux kernel source, many Debian scripts,
+		etc.).	This <tt>echo -n</tt> 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.
+	      </footnote>
+	    </item>
+	    <item>the <tt>-a</tt> and <tt>-o</tt> <tt>test</tt> operators
+	      must be supported</item>
+	    <item><tt>local</tt> to create a scoped variable must be
+	      supported; however, <tt>local</tt> may or may not preserve
+	      the variable value from an outer scope and may or may not
+	      support arguments more complex than simple variable
+	      names</item>
+	  </list>
 	  Thus, shell scripts specifying <file>/bin/sh</file> 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., <tt>#!/bin/bash</tt>) and the package must
-	  depend on the package providing the shell (unless the shell
-	  package is marked "Essential", as in the case of
-	  <prgn>bash</prgn>).
+	  interpreter must only use POSIX features or features guaranteed
+	  by the above list. If a script requires other non-POSIX features
+	  from the shell interpreter, the appropriate shell must be
+	  specified in the first line of the script (e.g.,
+	  <tt>#!/bin/bash</tt>) and the package must depend on the package
+	  providing the shell (unless the shell package is marked
+	  "Essential", as in the case of <prgn>bash</prgn>).
 	</p>
 
 	<p>
-	  You may wish to restrict your script to POSIX features when
-	  possible so that it may use <file>/bin/sh</file> as its
-	  interpreter. If your script works with <prgn>dash</prgn>
-	  (originally called <prgn>ash</prgn>), it's probably POSIX
-	  compliant, but if you are in doubt, use
+	  You may wish to restrict your script to POSIX features plus the
+	  above set when possible so that it may use <file>/bin/sh</file>
+	  as its interpreter. If your script works with <prgn>dash</prgn>
+	  (originally called <prgn>ash</prgn>), it probably complies with
+	  the above requirements, but if you are in doubt, use
 	  <file>/bin/bash</file>.
 	</p>
 
-- 
Russ Allbery (rra@debian.org)               <http://www.eyrie.org/~eagle/>



Reply to: