diff options
Diffstat (limited to 'shell')
-rw-r--r-- | shell/ash.c | 9 | ||||
-rw-r--r-- | shell/hush.c | 2 |
2 files changed, 8 insertions, 3 deletions
diff --git a/shell/ash.c b/shell/ash.c index b4b0d52..42e14cb 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -12981,13 +12981,18 @@ trapcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) return 0; } + /* Why the second check? + * "trap NUM [sig2]..." is the same as "trap - NUM [sig2]..." + * In this case, NUM is signal no, not an action. + */ action = NULL; - if (ap[1]) + if (ap[1] && !is_number(ap[0])) action = *ap++; + exitcode = 0; while (*ap) { signo = get_signum(*ap); - if (signo < 0 || signo >= NSIG) { + if (signo < 0) { /* Mimic bash message exactly */ ash_msg("%s: invalid signal specification", *ap); exitcode = 1; diff --git a/shell/hush.c b/shell/hush.c index f9dad07..11b33f4 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -9745,7 +9745,7 @@ static int FAST_FUNC builtin_trap(char **argv) sighandler_t handler; sig = get_signum(*argv++); - if (sig < 0 || sig >= NSIG) { + if (sig < 0) { ret = EXIT_FAILURE; /* Mimic bash message exactly */ bb_error_msg("trap: %s: invalid signal specification", argv[-1]); |