Mailinglist Archive: opensuse-packaging (130 mails)

< Previous Next >
Re: [opensuse-packaging] Proposal for a shell scripting policy
  • From: Stephan Kulow <coolo@xxxxxxx>
  • Date: Wed, 24 Mar 2010 10:58:30 +0100
  • Message-id: <201003241058.31585.coolo@xxxxxxx>
Am Mittwoch 24 März 2010 schrieb Guido Berhoerster:
Here is a rpmlint check which helps finding bashisms in /bin/sh
scripts, it produces errors if dash -n fails and informational
messages if checkbashisms finds anything (since it is just an
indicators and produces false positives).
It requires dash and checkbashism to be installed (the former is
in factory the latter can be obtained at
http://git.debian.org/?p=devscripts/devscripts.git)

How about putting it into the dash package for now?

To give the list an idea about what we're talking in practise I ran
it over my 11.2 init scripts (those we need to have fixed urgently if we
want to make dash an option) - only examples below:

possible bashism in /etc/init.d/ypbind line 86 (should be >word 2>&1):
ypwhich &>/dev/null && { notfound=0 ; break; };
possible bashism in /etc/init.d/xinetd line 88 ('$(< foo)' should be '$(cat
foo)'):
pid=$(<$XINETD_PIDFILE)
possible bashism in /etc/init.d/smartd line 80 ($"foo" should be eval_gettext
"foo"):
echo -n $"Reloading $prog daemon configuration: "
possible bashism in /etc/init.d/smbfs line 80 ('$[' should be '$(('):
timer=$[${timer}-1]
possible bashism in /etc/init.d/syslog line 90 (should be 'b = a'):
test "$1" == "stop" && exit 0
possible bashism in /etc/init.d/reboot line 175 (echo -e):

echo -e "$rc_done_up"
possible bashism in /etc/init.d/openvpn line 71 (shopt):

shopt -s nullglob
possible bashism in /etc/init.d/ntp line 88 ('function' is useless):

function ntpd_is_running() {

None of these cases are what Michael names "visually more pleasing". For many
of those
I would even argue that the "pure" version is easier to parse to the human eyes.

There are surely some cases that are debatable, e.g. the function keyword is
nice to have,
but wouldn't justify a /bin/bash bang IMO. The shopt one (if really needed)
surely is.

And the echo one I have no idea about: I wonder how debian handles this problem.

Greetings, Stephan
--
To unsubscribe, e-mail: opensuse-packaging+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse-packaging+help@xxxxxxxxxxxx

< Previous Next >
Follow Ups