ash: allow "trap NUM [SIG]..." syntax

While at it, make get_signum() return -1 for numeric strings >= NSIG.

function                                             old     new   delta
trapcmd                                              292     306     +14
get_signum                                           295     300      +5
builtin_trap                                         413     412      -1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 19/-1)              Total: 18 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko
2017-07-25 20:06:17 +02:00
parent f1a5cb0548
commit 86981e3ad2
4 changed files with 10 additions and 5 deletions

View File

@@ -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]);