[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Numbered signals for shell trap cause z/OS grief
From: |
Bruno Haible |
Subject: |
Re: Numbered signals for shell trap cause z/OS grief |
Date: |
Sat, 26 Nov 2022 19:51:05 +0100 |
I wrote:
> In fact, such a warning would make sense also in bash on Linux, for signals
> 7, 10, 12, and ≥ 16.
Thinking more about it: Such a warning in the *shell* is misplaced, because
it's perfectly OK to auto-generate a shell script for a particular machine
that runs on a particular platform. What is wrong is when a programmer
writes such a script and wants to it portably. Thus, the right place where
to produce this warning is a developer tool such as shellcheck.
I was just about to report it to the shellcheck people, when I saw that they
have implemented it already:
======================== foo.sh ========================
#!/bin/sh
trap 'rm -f foo' 0 1 2 3 7 10 12 15 17
========================================================
$ shellcheck foo.sh
In foo.sh line 3:
trap 'rm -f foo' 0 1 2 3 7 10 12 15 17
^-- SC2172 (warning): Trapping signals by number is
not well defined. Prefer signal names.
^-- SC2172 (warning): Trapping signals by number is
not well defined. Prefer signal names.
^-- SC2172 (warning): Trapping signals by number
is not well defined. Prefer signal names.
^-- SC2172 (warning): Trapping signals by
number is not well defined. Prefer signal names.
For more information:
https://www.shellcheck.net/wiki/SC2172 -- Trapping signals by number is not...
They warn about signal 7, 10, 12, 17, but not about 0, 1, 2, 3, 6, 9, 14, 15.
Mike Fulton wrote:
> a very subtle potential problem for z/OS.
Yes.
<https://man7.org/linux/man-pages/man7/signal.7.html>
<https://www.ibm.com/docs/en/zos/2.2.0?topic=SSLTBW_2.2.0/com.ibm.zos.v2r1.bpxb100/signals.html>
You can convince the shellcheck people to warn also about 'trap' of signal 3
(SIGQUIT vs. SIGABRT) and signal 6 (SIGABRT vs. SIGURG). Their bug tracker is
here: https://github.com/koalaman/shellcheck/issues
Bruno