mirror of
https://github.com/sheumann/hush.git
synced 2024-11-05 06:07:00 +00:00
ash: trap with bad signal name should not abort
function old new delta trapcmd 236 271 +35 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
19158a837d
commit
496d5bf4c6
14
shell/ash.c
14
shell/ash.c
@ -12281,7 +12281,7 @@ trapcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
|
|||||||
{
|
{
|
||||||
char *action;
|
char *action;
|
||||||
char **ap;
|
char **ap;
|
||||||
int signo;
|
int signo, exitcode;
|
||||||
|
|
||||||
nextopt(nullstr);
|
nextopt(nullstr);
|
||||||
ap = argptr;
|
ap = argptr;
|
||||||
@ -12314,10 +12314,15 @@ trapcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
|
|||||||
action = NULL;
|
action = NULL;
|
||||||
if (ap[1])
|
if (ap[1])
|
||||||
action = *ap++;
|
action = *ap++;
|
||||||
|
exitcode = 0;
|
||||||
while (*ap) {
|
while (*ap) {
|
||||||
signo = get_signum(*ap);
|
signo = get_signum(*ap);
|
||||||
if (signo < 0)
|
if (signo < 0) {
|
||||||
ash_msg_and_raise_error("%s: bad trap", *ap);
|
/* Mimic bash message exactly */
|
||||||
|
ash_msg("%s: invalid signal specification", *ap);
|
||||||
|
exitcode = 1;
|
||||||
|
goto next;
|
||||||
|
}
|
||||||
INT_OFF;
|
INT_OFF;
|
||||||
if (action) {
|
if (action) {
|
||||||
if (LONE_DASH(action))
|
if (LONE_DASH(action))
|
||||||
@ -12330,9 +12335,10 @@ trapcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
|
|||||||
if (signo != 0)
|
if (signo != 0)
|
||||||
setsignal(signo);
|
setsignal(signo);
|
||||||
INT_ON;
|
INT_ON;
|
||||||
|
next:
|
||||||
ap++;
|
ap++;
|
||||||
}
|
}
|
||||||
return 0;
|
return exitcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
4
shell/ash_test/ash-signals/signal4.right
Normal file
4
shell/ash_test/ash-signals/signal4.right
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
./signal4.tests: trap: line 3: BADNAME: invalid signal specification
|
||||||
|
1
|
||||||
|
Trapped
|
||||||
|
Ok
|
5
shell/ash_test/ash-signals/signal4.tests
Executable file
5
shell/ash_test/ash-signals/signal4.tests
Executable file
@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
trap "echo Trapped" BADNAME TERM; echo $?
|
||||||
|
kill $$
|
||||||
|
echo Ok
|
Loading…
Reference in New Issue
Block a user