FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Debian > Debian Development

 
 
LinkBack Thread Tools
 
Old 09-28-2011, 11:01 AM
Thomas Hood
 
Default Eliminating bash scripts?

Recently I noticed some bug reports asking that scripts berewritten to run on (POSIX) sh. �These weren't the familiar(and completely justified) complaints about bashisms in scripts

shebanged #!/bin/sh.�These were requests to rewrite #!/bin/bashscripts as #!/bin/sh�scripts. �Why do this? �The following reasonswere advanced.


* The package then has fewer dependencies* ... and can then be installed on a system without bash.* When /bin/sh is dash, the script will run faster* ... and will run on a shell which is smaller and thus less buggy

* ... and more secure* ... and, after all, standard, whereas bash is not,* ... and consequently better understood by programmers,* ... and portable, whereas bash is not.* Indeed, dash is the future whereas bash is history.

* If sed has to be used, that OK, its regexps are better thanbash's extended globs.
I wonder what Debian folk think about these claims. �
Should�we be aiming to eliminate all bash scripts from Debian?


Are there real-world Debian systems that are "minimal"�enoughto have trouble running bash, but not so minimal�that busyboxhas to be used?
One thing I would like to point out immediately is that a bash

script�will not necessarily run faster if it has to be rewrittento run on sh. �This is especially true if ${//}s are replaced by�pipes to sed.--�Thomas Hood
 
Old 09-28-2011, 12:25 PM
Neil Williams
 
Default Eliminating bash scripts?

On Wed, 28 Sep 2011 13:01:45 +0200
Thomas Hood <jdthood@gmail.com> wrote:

> * The package then has fewer dependencies
> * ... and can then be installed on a system without bash.

Unless the package is doing a lot of clever stuff in shell (at which
point it is possibly worth asking if the package should use a faster
interpreted language like perl - which will be installed even if bash
is not - or converted to a compiled tool), the reasons to
keep #!/bin/bash are likely to be inertia.

> * When /bin/sh is dash, the script will run faster
> * ... and will run on a shell which is smaller and thus less buggy

Not necessarily true.

> * ... and more secure

Not necessarily true.

> * Indeed, dash is the future whereas bash is history.

Opinion.

> Should we be aiming to eliminate all bash scripts from Debian?

I see no good reasons.

> Are there real-world Debian systems that are "minimal" enough
> to have trouble running bash, but not so minimal that busybox
> has to be used?

Such systems would probably involve some form of embedded usage and
most people investigating such things could be expected to at least ask
on the debian-embedded lists or #emdebian on IRC. I don't miss many
queries on either of those and I cannot remember a single instance of
anyone wanting to remove bash but keep dash.

If bash is a problem then perl is a bigger problem and dash is not the
solution. The solution is busybox which means removing coreutils and a
whole world of fettling. i.e. Emdebian Crush.

> One thing I would like to point out immediately is that a bash
> script will not necessarily run faster if it has to be rewritten
> to run on sh. This is especially true if ${//}s are replaced by
> pipes to sed.

All the more reason to make the rewrite in a different language. If the
tool isn't likely to be needed on minimal systems where the only
available shell is busybox, then a rewrite in perl, python or something
else would seem appropriate. If it could be used with busybox, the only
really sane option is to compile it.

--


Neil Williams
=============
http://www.linux.codehelp.co.uk/
 
Old 09-28-2011, 01:15 PM
Ian Jackson
 
Default Eliminating bash scripts?

Thomas Hood writes ("Eliminating bash scripts?"):
> Recently I noticed some bug reports asking that scripts be
> rewritten to run on (POSIX) sh. These weren't the familiar
> (and completely justified) complaints about bashisms in scripts
> shebanged #!/bin/sh. These were requests to rewrite #!/bin/bash
> scripts as #!/bin/sh scripts. Why do this? The following reasons
> were advanced.
> [stuff]
...
> I wonder what Debian folk think about these claims.

I think it depends on the script. There are also some very good
reasons to use bash rather than dash. bash has some important
features which are either very hard to emulate in dash, or where the
alternatives are often annoyingly clumsy:
* Array variables
* set -o pipefail / ${PIPESTATUS[*]}
* shopt -s nullglob / failglob
* glob substitutions ${//} etc.
* bunches of other niche stuff which is very useful if you
happen to want it (eg, RANDOM, disown)

If some part of your program uses these features extensively, it can
be quite a bit of work to change it. I would need a compelling reason
to do so.

One also needs to think about the environment the script might run
in. I think, for example, that it's perfectly reasonable to expect
bash to be installed when doing package builds, so I have no
hesitation in using bashisms freely in build and packaging scripts.

Also for desktop systems running gnome, kde, web browsers, etc., the
additional cost of bash is negligible. So packages aimed at those
environments can also sensibly use bash.

On the other hand, there is a lot of potential benefit to getting rid
of the dependency on bash for essential packages - even if we can't
get bash out of essential in Debian proper, derivatives might do so.

> * The package then has fewer dependencies
> * ... and can then be installed on a system without bash.
> * When /bin/sh is dash, the script will run faster
> * ... and will run on a shell which is smaller and thus less buggy

These are probably true (although dash used to be quite buggy, it's
much less so now).

> * ... and more secure
> * ... and, after all, standard, whereas bash is not,
> * ... and consequently better understood by programmers,
> * ... and portable, whereas bash is not.

These reasons are at best doubtful.

> * Indeed, dash is the future whereas bash is history.
> * If sed has to be used, that OK, its regexps are better than
> bash's extended globs.

And these are by and large false.

> Should we be aiming to eliminate all bash scripts from Debian?

No. But it might be worthwhile seeing if we can get rid of it from
essential, for example.

Ian.


--
To UNSUBSCRIBE, email to debian-devel-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 20099.7661.214781.947719@chiark.greenend.org.uk">h ttp://lists.debian.org/20099.7661.214781.947719@chiark.greenend.org.uk
 
Old 09-28-2011, 02:59 PM
Simon McVittie
 
Default Eliminating bash scripts?

On Wed, 28 Sep 2011 at 13:01:45 +0200, Thomas Hood wrote:
> * The package then has fewer dependencies
> * ... and can then be installed on a system without bash.

This doesn't help Debian directly, but it may help upstreams to be portable
to operating systems with a reason to use a non-bash shell - embedded systems
with Busybox, BSDs with ideological objections to the GPL, proprietary Unixes
with a grudgingly-POSIX-compliant proprietary shell.

> * If sed has to be used, that OK, its regexps are better than
> bash's extended globs.

If you can use ${x%%y}, ${x#y} etc. to achieve the same effect (you often can),
you get the best of both worlds. I believe they're specified by POSIX;
certainly, current dash supports them, and they're in the SUS.

Otherwise, it's a trade-off. Basic use of sed + sh should work on most
Busybox-based embedded systems and on any POSIX-compliant Unix, whereas
bash is a non-standard addition - but on the other hand, bash extended
globs save a fork().

> Should we be aiming to eliminate all bash scripts from Debian?

IMO: if there are bash scripts that can be converted into POSIX sh scripts
easily, why not? but if it would make the script significantly less
maintainable, your time is usually more valuable than your CPU's.

S


--
To UNSUBSCRIBE, email to debian-devel-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 20110928145940.GB17366@reptile.pseudorandom.co.uk" >http://lists.debian.org/20110928145940.GB17366@reptile.pseudorandom.co.uk
 
Old 10-01-2011, 12:27 AM
David Weinehall
 
Default Eliminating bash scripts?

On Wed, Sep 28, 2011 at 03:59:40PM +0100, Simon McVittie wrote:
[snip]

> If you can use ${x%%y}, ${x#y} etc. to achieve the same effect (you
> often can), you get the best of both worlds. I believe they're
> specified by POSIX; certainly, current dash supports them, and they're
> in the SUS.

SuSv3 -- POSIX:2001
SuSv4 -- POSIX:2008

So if they're in SuS, they're specified by POSIX

While I've read the SuSv3 quite thoroughly, I have yet to study the
SuSv4, so I dunno how big the differences are, and if any of them are
important.


Regards: David
--
/) David Weinehall <tao@debian.org> /) Rime on my window (
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Diamond-white roses of fire //
) http://www.acc.umu.se/~tao/ (/ Beautiful hoar-frost (/


--
To UNSUBSCRIBE, email to debian-devel-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 20111001002700.GK16847@suiko.acc.umu.se">http://lists.debian.org/20111001002700.GK16847@suiko.acc.umu.se
 

Thread Tools




All times are GMT. The time now is 12:05 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org