Hello, following up the discussion on upstart and init scripts I'd like to propose a new policy on shell scripting. Shell scripting policy ---------------------- /bin/sh can be only expected to support the SUSv3 Shell Command Language, this allows dash, ksh, and bash to become /bin/sh. Init scripts should use /bin/sh, but may use /bin/bash with proper justification, e.g. not just for using ==, [[ ]], or echo -e which are easily replaced by SUSv3 compliant constructs. New packages containing scripts using /bin/sh must be tested with dash as /bin/sh (dash -n/checkbashisms.pl may aid debugging but are not sufficient by themselves). Any errors should be fixed and reported upstream. The rpm specfiles and scriptlets use bash and a GNU userland by default (I think everything else would be a pain to fix because of the many bashisms and GNUisms in specfiles). Rationale --------- * Choice and diversity are good: the ulimate goal would be to allow any SUSv3 compatible shell in openSUSE (currently ksh93, bash, and dash) to be used as /bin/sh * Quality and Correctness: /bin/sh is not /bin/bash, using other shells may expose bugs, corner cases etc. * Speed: bash is slow, allowing scripts to run on other shells such as dash or ksh93 may lead to speedups in certain situations * Portability: allow the re-use of scripts written for openSUSE on other OS What other distros are doing ---------------------------- Fedora does not seem to have a policy on shell scripts, according to the Debian policy handbook (which also applies to Ubuntu) /bin/sh can only be assumed to support the SUSv3 Command Language whith three exceptions, those are support of echo -n, test -a/-o and local. Note that this is not entirely correct, echo -n, test -a/-o are as XSI extensions part of the SUSv3 just not POSIX. Implementation -------------- The implementation of this policy could happen gradually over time assisted by a new rpmlint check which uses dash -n and checkbashisms.pl. In my opinion %_buildshell should point to /bin/bash, simply because fixing all the bashisms and gnuisms (pushd, popd, == etc.) in specfiles would be too much work. Building packages with dash as /bin/sh may expose bugs in build systems which will need to be fixed upstream. However, since Debian and Ubuntu have been doing this for some time, many issues are likely to be resolved already and there is pressure on upstream maintainers to fix their scripts. In the long term /bin/sh could default to dash, choosing ksh93 and bash should remain a possibility through the use of update-alternatives. Finally, here is a rough estimate on the scale of the issue: * on February 22nd the Factory OSS Repository (i586/i686/noarch) contained 8002 binary packages * there are 4065 /bin/sh scripts (267 of which are init scripts) in 1092 packages, furthermore there are 3481 /bin/sh rpm scriptlets in 1488 packages * checkbashisms.pl shows warnings for 794 scripts (100 of which are init scripts) in 372 packets (note that checkbashisms.pl is not very reliable) * dash -n leads shows syntax errors in 356 scripts (16 of which are init scripts) in 111 packages (haowever this does not detect all errors) Comments, Suggestions? -- Guido Berhoerster -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-packaging+help@opensuse.org