Bug#843600: checkbashishm should warn about trap with SIG-something names
Carlos Alberto Lopez Perez
clopez at igalia.com
Tue Nov 8 00:04:08 UTC 2016
Package: devscripts
Version: 2.16.8
Hi,
It seems that referring to the signals with a SIG prefix is not
something that has to be supported by the POSIX standard:
http://pubs.opengroup.org/onlinepubs/000095399/utilities/trap.html:
""""
RATIONALE
Implementations may permit lowercase signal names as an extension.
Implementations may also accept the names with the SIG prefix; no known
historical shell does so. The trap and kill utilities in this volume of
IEEE Std 1003.1-2001 are now consistent in their omission of the SIG
prefix for signal names. Some kill implementations do not allow the
prefix, and kill -l lists the signals without prefixes.
Trapping SIGKILL or SIGSTOP is syntactically accepted by some
historical implementations, but it has no effect. Portable POSIX
applications cannot attempt to trap these signals.
""""
And this is major problem, because our default /bin/sh (dash) fails to
run scripts using SIGSOMETHING.
Check this example:
$ cat test.sh
#/bin/sh
trap "echo hi from int" SIGINT
kill -INT $$
$ bash test.sh
hi from int
$ dash test.sh
trap: SIGINT: bad trap
$ sh test.sh
trap: SIGINT: bad trap
$ ./test.sh
trap: SIGINT: bad trap
To fix the script, SIGINT should be replaced with INT
So I think checkbashishm should warn always that it finds SIGSOMETHING
on a trap line.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 883 bytes
Desc: OpenPGP digital signature
URL: <http://lists.alioth.debian.org/pipermail/devscripts-devel/attachments/20161108/01a24bc4/attachment.sig>
More information about the devscripts-devel
mailing list