diff options
author | Denys Vlasenko | 2010-03-26 15:52:24 +0100 |
---|---|---|
committer | Denys Vlasenko | 2010-03-26 15:52:24 +0100 |
commit | 496d5bf4c6566b7837e61fa83da3fb5851ae446b (patch) | |
tree | f91880f67012bccd6f3432e3bb4f34ec2a71cefc /shell | |
parent | 19158a837df5093a2d655536424412bac2b07467 (diff) | |
download | busybox-496d5bf4c6566b7837e61fa83da3fb5851ae446b.zip busybox-496d5bf4c6566b7837e61fa83da3fb5851ae446b.tar.gz |
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>
Diffstat (limited to 'shell')
-rw-r--r-- | shell/ash.c | 14 | ||||
-rw-r--r-- | shell/ash_test/ash-signals/signal4.right | 4 | ||||
-rwxr-xr-x | shell/ash_test/ash-signals/signal4.tests | 5 |
3 files changed, 19 insertions, 4 deletions
diff --git a/shell/ash.c b/shell/ash.c index e285130..0cfa4fc 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -12281,7 +12281,7 @@ trapcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) { char *action; char **ap; - int signo; + int signo, exitcode; nextopt(nullstr); ap = argptr; @@ -12314,10 +12314,15 @@ trapcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) 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)) @@ -12330,9 +12335,10 @@ trapcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) if (signo != 0) setsignal(signo); INT_ON; + next: ap++; } - return 0; + return exitcode; } diff --git a/shell/ash_test/ash-signals/signal4.right b/shell/ash_test/ash-signals/signal4.right new file mode 100644 index 0000000..3260584 --- /dev/null +++ b/shell/ash_test/ash-signals/signal4.right @@ -0,0 +1,4 @@ +./signal4.tests: trap: line 3: BADNAME: invalid signal specification +1 +Trapped +Ok diff --git a/shell/ash_test/ash-signals/signal4.tests b/shell/ash_test/ash-signals/signal4.tests new file mode 100755 index 0000000..6f1c4a9 --- /dev/null +++ b/shell/ash_test/ash-signals/signal4.tests @@ -0,0 +1,5 @@ +#!/bin/sh + +trap "echo Trapped" BADNAME TERM; echo $? +kill $$ +echo Ok |