Debian Developers - Proposed new POSIX sh policy (was: First draft of review of policy must usage)

This is Interesting: Free IT Magazines  
Home > Archive > Debian Developers > November 2006 > Proposed new POSIX sh policy (was: First draft of review of policy must usage)





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Proposed new POSIX sh policy (was: First draft of review of policy must usage)
Russ Allbery

2006-11-06, 7:19 am

Russ Allbery <rra@debian.org> writes:
> Manoj Srivastava <srivasta@debian.org> writes:


[vbcol=seagreen]
> I can try to propose better language for this. I think that using pure
> bash-specific constructs not found in dash in /bin/sh scripts should
> actually be an RC bug, but using test -a or test -o should not. I think
> we need to say that /bin/sh scripts are permitted to use POSIX shell
> capabilities plus a short list of additional capabilities that
> everything other than posh also implement.


Here's a proposed patch. What do people think about this approach? I
know there was an inconclusive Policy discussion a while back about how
best to deal with this issue. As you can tell from this patch, I favor
the approach of documenting the specific features that we require and
assuming that their semantics are sufficiently clear in practice.

This patch would resolve Policy bug #294962 as well.

--- orig/policy.sgml
+++ mod/policy.sgml
@@ -6727,25 +6727,34 @@

<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</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>

--
Russ Allbery (rra@debian.org) <http://www.eyrie.org/~eagle/>


--
To UNSUBSCRIBE, email to debian-policy-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Michal Politowski

2006-11-06, 7:19 am

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.

--
Micha³ Politowski
Talking has been known to lead to communication if practiced carelessly.

Mike Hommey

2006-11-06, 7:19 am

On Sun, Nov 05, 2006 at 07:41:40PM -0800, Russ Allbery <rra@debian.org> wrote:
> + <item>the <tt>-a</tt> and <tt>-o</tt> <tt>test</tt> operators
> + must be supported</item>


Why is that needed ?

Mike


--
To UNSUBSCRIBE, email to debian-policy-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Andreas Barth

2006-11-06, 7:19 am

* Russ Allbery (rra@debian.org) [061106 04:41]:
> Here's a proposed patch. What do people think about this approach?


Sounds good, thanks for your work.


Cheers,
Andi
--
http://home.arcor.de/andreas-barth/


--
To UNSUBSCRIBE, email to debian-devel-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Wouter Verhelst

2006-11-06, 1:18 pm

On Sun, Nov 05, 2006 at 07:41:40PM -0800, Russ Allbery wrote:
> Russ Allbery <rra@debian.org> writes:
>
>
>
> Here's a proposed patch. What do people think about this approach?

[...]

It looks good to me. Perhaps it would be nice if the policy would
mention that "the use of non-POSIX constructs should be avoided if
possible", but I don't think it's important either way.

--
<Lo-lan-do> Home is where you have to wash the dishes.
-- #debian-devel, Freenode, 2004-09-22


--
To UNSUBSCRIBE, email to debian-policy-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Zack Weinberg

2006-11-06, 1:18 pm

I'd like to see this say something about what may be assumed of the
standard shell utilities, as well as the shell itself, and in
particular I'd like to see coreutils bug #339085 addressed [please see
the bug log for my personal very strong opinion on which way it should
be addressed].

zw


--
To UNSUBSCRIBE, email to debian-policy-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Marco d'Itri

2006-11-07, 1:31 am

On Nov 06, Thomas Bushnell BSG <tb@becket.net> wrote:

> Russ's patch is no good, at least, it does not address the problems I
> have raised in the past.

It's still better than what we have now, and solving parts of the
problems is still better than waiting for the ultimate policy change
which will fix all of them.

--
ciao,
Marco

Marco d'Itri

2006-11-07, 1:31 am

On Nov 06, Mike Hommey <mh@glandium.org> wrote:

> Why is that needed ?

Because every modern shell which is not designed to be broken supports
them, and since they are in widespread use everywhere there is no reason
to no support them.

I appreciate this attempt to formalize the de facto policy and support
it.

--
ciao,
Marco

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com