On Mon, Jun 23, 2008 at 10:07:27AM +0200, Michael Meskes wrote:
With our move to dash as sh we have to remove all bashisms from scripts
run by /bin/sh. However, checkbashism seems to moan about clauses that
work in dash as well. I don't know in which shells a trap with a signal number
is guaranteed to work, but it seems to work well in dash.

As far as I'm aware, there are three shells in Debian that can be used
as /bin/sh: bash, dash, and posh[0].  bash is, in general, the most
featureful of these.  Just because something works in one does not mean
that it works in all of them.  Notably, posh implements the most minimal
set of features, and last time I checked, my system failed to boot
because scripts were using features not mandated by policy.

So, if you're going to fix bugs due to bashisms, please fix them all.
They are all policy violations, and there's no reason to fix only some
bugs.

As for the signal numbers, different architectures have different signal
numbers.  See signal(7), but the most common ones *are* identical.
However, signals such as SIGUSR1 and SIGUSR2 are not, and using a number
for these will break on at least alpha, mips, mipsel, and sparc[1].  Using
names is not only more portable, it is more explicit.  Everyone knows
what SIGABRT does, but not everyone knows what signal 4 does.  Think of
using signal numbers as using magic numbers: it's a bad programming
practice.

Also, as GNU/kFreeBSD becomes more usable, it will be important to have
shell scripts work across kernels.  The FreeBSD kernel does not match
any Linux architecture in its assignment of signal numbers, so fixing
these now is a good idea.

[0] It would be nice if zsh were added to this list, but I'm not holding
my breath.
[1] Assuming, of course, that most people use i386 or amd64 as their
main platform, and program accordingly.  Judging by the number of FTBFS
bugs on sparc due to alignment problems, this is a safe assumption.

--
brian m. carlson / brian with sandals: Houston, Texas, US
+1 713 440 7475 | http://crustytoothpaste.ath.cx/~bmc | My opinion only
troff on top of XML: http://crustytoothpaste.ath.cx/~bmc/code/thwack
OpenPGP: RSA v4 4096b 88AC E9B2 9196 305B A994 7552 F1BA 225C 0223 B187

Attachment: signature.asc
Description: Digital signature

Reply via email to