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-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/20099.7661.214781.947...@chiark.greenend.org.uk