|
Home > Archive > Debian Developers > August 2004 > /bin/sh == bash?
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]
|
|
|
|
| Andreas Metzler 2004-08-06, 5:55 pm |
| On 2004-08-06 Roland Stigge <stigge@antcom.de> wrote:
> I recently encountered some packages (e.g.
> fhist: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=263997
> userv: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=263979
> ) that FTBFS when /bin/sh is not bash, but instead a more POSIX like
> shell, e.g. dash. See also Policy, 10.4. Scripts.
> What is the correct severity for this kind of bug?
Imho serious, we use that severity both for FTBFS and for /bin/sh
scripts using bash-extensions in the finished package.
cu andreas
--
To UNSUBSCRIBE, email to debian-devel-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
| |
| Clint Adams 2004-08-06, 5:55 pm |
| > What is the correct severity for this kind of bug?
serious
--
To UNSUBSCRIBE, email to debian-devel-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
| |
| Jérôme Marant 2004-08-06, 5:55 pm |
| Selon Roland Stigge <stigge@antcom.de>:
> Hi,
>
> I recently encountered some packages (e.g.
> fhist: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=263997
> userv: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=263979
> ) that FTBFS when /bin/sh is not bash, but instead a more POSIX like
> shell, e.g. dash. See also Policy, 10.4. Scripts.
Doesn't this problem happen in debian/rules? (I can see
make: *** [install-stamp] Error 1 at the bottom)
In that case, SHELL=/bin/bash at the beginning of debian/rules
works fine.
Cheers,
--
Jérôme Marant
--
To UNSUBSCRIBE, email to debian-devel-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
| |
| David Weinehall 2004-08-06, 5:55 pm |
| On Fri, Aug 06, 2004 at 10:14:55PM +0200, Jérôme Marant wrote:
> Selon Roland Stigge <stigge@antcom.de>:
>
Note that even if things work with dash, it doesn't really say too much
about POSIX (and hence policy 10.4) compliance, dash has quite a lot of
extensions. posh is probably the closest thing to POSIX we have in
Debian. It'll cause quite a lot of scripts to fail though, since it
doesn't support `command -v', which is something we even recommend in
policy. Imho `command -v' should be explicitly added to Policy 10.4,
alongside the extension we already have there, `echo -n'.
[vbcol=seagreen]
> Doesn't this problem happen in debian/rules? (I can see
> make: *** [install-stamp] Error 1 at the bottom)
>
> In that case, SHELL=/bin/bash at the beginning of debian/rules
> works fine.
Please, usually the non-POSIX stuff is easy to remove, and just papering
over the problems by using SHELL=/bin/bash should only be used as
a solution when no other option seems reasonably possible.
Regards: David weinehall
--
/) David Weinehall <tao@acc.umu.se> /) Northern lights wander (\
// Maintainer of the v2.0 kernel // Dance across the winter sky //
\) http://www.acc.umu.se/~tao/ (/ Full colour fire (/
--
To UNSUBSCRIBE, email to debian-devel-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
| |
| Roland Stigge 2004-08-06, 5:55 pm |
| Hi,
you wrote:
> Doesn't this problem happen in debian/rules? (I can see
> make: *** [install-stamp] Error 1 at the bottom)
Exactly.
> In that case, SHELL=/bin/bash at the beginning of debian/rules
> works fine.
Right.
Thanks everyone for answering (and quite consistently). But there are
quite some of those package. You have been warned. Easy to fix,
though...
bye,
Roland
--
To UNSUBSCRIBE, email to debian-devel-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
| |
| Jérôme Marant 2004-08-06, 5:55 pm |
| Selon David Weinehall <tao@debian.org>:
>
> Please, usually the non-POSIX stuff is easy to remove, and just papering
> over the problems by using SHELL=/bin/bash should only be used as
> a solution when no other option seems reasonably possible.
The bash package is an essential package in Debian, which means
that the solution I gave will always work.
--
Jérôme Marant
--
To UNSUBSCRIBE, email to debian-devel-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
| |
| Jérôme Marant 2004-08-06, 5:55 pm |
| Selon David Weinehall <tao@debian.org>:
> On Fri, Aug 06, 2004 at 10:14:55PM +0200, Jérôme Marant wrote:
>
> Note that even if things work with dash, it doesn't really say too much
> about POSIX (and hence policy 10.4) compliance, dash has quite a lot of
> extensions. posh is probably the closest thing to POSIX we have in
> Debian. It'll cause quite a lot of scripts to fail though, since it
> doesn't support `command -v', which is something we even recommend in
> policy. Imho `command -v' should be explicitly added to Policy 10.4,
> alongside the extension we already have there, `echo -n'.
After rereading 10.4, it is clear that POSIX compliance is not mandatory
at all.
--
Jérôme Marant
--
To UNSUBSCRIBE, email to debian-devel-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
| |
|
|
| David Weinehall 2004-08-07, 2:47 am |
| On Fri, Aug 06, 2004 at 10:43:18PM +0200, Jérôme Marant wrote:
> Selon David Weinehall <tao@debian.org>:
>
>
> After rereading 10.4, it is clear that POSIX compliance is not mandatory
> at all.
``The standard shell interpreter `/bin/sh' can be a symbolic link to
any POSIX compatible shell, if `echo -n' does not generate a newline.[1]
Thus, shell scripts specifying `/bin/sh' as interpreter should 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').''
Well, you have the option of _either_ using only POSIX features, _or_
specifying the appropriate shell. Hence the ``should'' in
"Thus, shell scripts specifying `/bin/sh' as interpreter should
only use POSIX features." really only makes any sense if replaced
with a must. Of course, there is a third option -- having a script that
fails to work when using a strict POSIX shell, but that implies FTBFS or
runtime failures, which really isn't an option either.
Hence I cannot really see how you can say that it's "clear that POSIX
compliance is not mandatory at all".
Regards: David Weinehall
--
/) David Weinehall <tao@acc.umu.se> /) Northern lights wander (\
// Maintainer of the v2.0 kernel // Dance across the winter sky //
\) http://www.acc.umu.se/~tao/ (/ Full colour fire (/
--
To UNSUBSCRIBE, email to debian-devel-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
| |
| Hamish Moffatt 2004-08-07, 2:47 am |
| On Fri, Aug 06, 2004 at 10:29:55PM +0200, David Weinehall wrote:
> Please, usually the non-POSIX stuff is easy to remove, and just papering
> over the problems by using SHELL=/bin/bash should only be used as
> a solution when no other option seems reasonably possible.
But why? Often the bashisms make scripts much more readable (and
therefore maintainable). Especially for package build scripts.
And bash is essential, so why not use it?
I can see that a minimal Debian system (eg an embedded system) might
want to omit bash to save space, but a development system could always
include it.
Next thing you'll ask me to stop using VIM too 
Hamish
--
Hamish Moffatt VK3SB <hamish@debian.org> <hamish@cloud.net.au>
--
To UNSUBSCRIBE, email to debian-devel-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
| |
| Jérôme Marant 2004-08-07, 2:47 am |
| Selon David Weinehall <tao@debian.org>:
>
> ``The standard shell interpreter `/bin/sh' can be a symbolic link to
> any POSIX compatible shell, if `echo -n' does not generate a newline.[1]
> Thus, shell scripts specifying `/bin/sh' as interpreter should 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').''
>
> Well, you have the option of _either_ using only POSIX features, _or_
> specifying the appropriate shell. Hence the ``should'' in
> "Thus, shell scripts specifying `/bin/sh' as interpreter should
> only use POSIX features." really only makes any sense if replaced
> with a must. Of course, there is a third option -- having a script that
> fails to work when using a strict POSIX shell, but that implies FTBFS or
> runtime failures, which really isn't an option either.
>
> Hence I cannot really see how you can say that it's "clear that POSIX
> compliance is not mandatory at all".
I stand correct: POSIX compliance is only necessary when using /bin/sh.
It doesn't force anyone to use a POSIX-compliant shell. In that case,
you need to give the precise name of the shell.
So, two ways of fixing: fixing the script for POSIX-compliance *OR*
SHELL=/bin/bash at the beginning of debian/rules (or /bin/bash in
shell scripts). Both solutions are valid.
--
Jérôme Marant
--
To UNSUBSCRIBE, email to debian-devel-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
| |
| David Weinehall 2004-08-07, 2:47 am |
| On Sat, Aug 07, 2004 at 10:26:48AM +1000, Hamish Moffatt wrote:
> On Fri, Aug 06, 2004 at 10:29:55PM +0200, David Weinehall wrote:
>
> But why? Often the bashisms make scripts much more readable (and
> therefore maintainable). Especially for package build scripts.
Well, I don't think I agree about often, but they do admittedly
sometimes. But most of the non-POSIX stuff I run into are:
`-a' and `-o' in tests; `&&' and `||' are at least as readable,
especially since `-a' is overloaded (a ksh:ism supported by bash; use
`-e' instead)
source <filename>; . <filename> is arguably a bit less expressive, but
not to the point of unreadability
function bla; bla() is at least as readable
kill -<signum>; I'd say kill -s <sigspec> is far more readable
trap "..." <signum>; I'd say trap "..." <sigspec> is far more readable
pushd <dir> .... popd; (cd <dir> ....) is imho at least as readable
> And bash is essential, so why not use it?
>
> I can see that a minimal Debian system (eg an embedded system) might
> want to omit bash to save space, but a development system could always
> include it.
Well, I both work with, and play with in my spare time, quite a lot
of embedded systems. And while indeed package build scripts using bash
is no problem at all, it's a well known fact that people code by
example, so use of bashisms, XSI:isms, etc in build scripts tend to
spread to the runtime scripts, and that's when things stop playing
nicely with embedded systems.
> Next thing you'll ask me to stop using VIM too 
Considering I use VIM for almost everything, including writing texts
that later end up in *cough* Word-documents, that would be a bit stupid
of me... =) The only other editor I use is the one built into
Evolution1.5, and that's only because I haven't found a GNOME component
of VIM yet. If anyone knows of one, I'd be glad to know.
Regards: David Weinehall
--
/) David Weinehall <tao@acc.umu.se> /) Northern lights wander (\
// Maintainer of the v2.0 kernel // Dance across the winter sky //
\) http://www.acc.umu.se/~tao/ (/ Full colour fire (/
--
To UNSUBSCRIBE, email to debian-devel-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
| |
| Thiemo Seufer 2004-08-07, 5:51 pm |
| David Weinehall wrote:
[snip]
>
> Well, I don't think I agree about often, but they do admittedly
> sometimes. But most of the non-POSIX stuff I run into are:
[snip]
> function bla; bla() is at least as readable
>
> kill -<signum>; I'd say kill -s <sigspec> is far more readable
>
> trap "..." <signum>; I'd say trap "..." <sigspec> is far more readable
>
> pushd <dir> .... popd; (cd <dir> ....) is imho at least as readable
The last change would affect the script's semantics. 'cd' calls aren't
easily nestable.
Thiemo
--
To UNSUBSCRIBE, email to debian-devel-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
| |
| David Weinehall 2004-08-07, 5:51 pm |
| On Sat, Aug 07, 2004 at 04:31:23PM +0200, Thiemo Seufer wrote:
> David Weinehall wrote:
> [snip]
> [snip]
>
> The last change would affect the script's semantics. 'cd' calls aren't
> easily nestable.
It's quite easy to nest calls to `cd'.
tao@smyslov:~$ (cd /usr/share/man; ls; (cd /etc; ls -d rc*); ls)
cs/ es_ES/ hu/ ja/ man2/ man5/ man8/ pt_BR/ sv/
de/ fr/ id/ ko/ man3/ man6/ man9/ ru/ tr/
es/ fr_FR/ it/ man1/ man4/ man7/ pl/ ru_RU/
rc0.d/ rc1.d/ rc2.d/ rc3.d/ rc4.d/ rc5.d/ rc6.d/ rcS.d/
cs/ es_ES/ hu/ ja/ man2/ man5/ man8/ pt_BR/ sv/
de/ fr/ id/ ko/ man3/ man6/ man9/ ru/ tr/
es/ fr_FR/ it/ man1/ man4/ man7/ pl/ ru_RU/
Nests just fine, imho... Of course, in a shell script, it could be
expressed a little nicer, with indentation.
Regards: David Weinehall
--
/) David Weinehall <tao@acc.umu.se> /) Northern lights wander (\
// Maintainer of the v2.0 kernel // Dance across the winter sky //
\) http://www.acc.umu.se/~tao/ (/ Full colour fire (/
--
To UNSUBSCRIBE, email to debian-devel-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
| |
| Thiemo Seufer 2004-08-07, 5:51 pm |
| David Weinehall wrote:
[snip]
>
> It's quite easy to nest calls to `cd'.
>
> tao@smyslov:~$ (cd /usr/share/man; ls; (cd /etc; ls -d rc*); ls)
> cs/ es_ES/ hu/ ja/ man2/ man5/ man8/ pt_BR/ sv/
> de/ fr/ id/ ko/ man3/ man6/ man9/ ru/ tr/
> es/ fr_FR/ it/ man1/ man4/ man7/ pl/ ru_RU/
> rc0.d/ rc1.d/ rc2.d/ rc3.d/ rc4.d/ rc5.d/ rc6.d/ rcS.d/
> cs/ es_ES/ hu/ ja/ man2/ man5/ man8/ pt_BR/ sv/
> de/ fr/ id/ ko/ man3/ man6/ man9/ ru/ tr/
> es/ fr_FR/ it/ man1/ man4/ man7/ pl/ ru_RU/
>
> Nests just fine, imho...
And loses unexported variables in turn.
Thiemo
--
To UNSUBSCRIBE, email to debian-devel-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
|
|
|
|
|