function old new delta
trapcmd 236 271 +35
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
{
char *action;
char **ap;
- int signo;
+ int signo, exitcode;
nextopt(nullstr);
ap = argptr;
action = NULL;
if (ap[1])
action = *ap++;
+ exitcode = 0;
while (*ap) {
signo = get_signum(*ap);
- if (signo < 0)
- ash_msg_and_raise_error("%s: bad trap", *ap);
+ if (signo < 0) {
+ /* Mimic bash message exactly */
+ ash_msg("%s: invalid signal specification", *ap);
+ exitcode = 1;
+ goto next;
+ }
INT_OFF;
if (action) {
if (LONE_DASH(action))
if (signo != 0)
setsignal(signo);
INT_ON;
+ next:
ap++;
}
- return 0;
+ return exitcode;
}
--- /dev/null
+./signal4.tests: trap: line 3: BADNAME: invalid signal specification
+1
+Trapped
+Ok
--- /dev/null
+#!/bin/sh
+
+trap "echo Trapped" BADNAME TERM; echo $?
+kill $$
+echo Ok