static int builtin_trap(char **argv)
{
- int i;
int sig;
char *new_cmd;
argv++;
if (!*argv) {
+ int i;
/* No args: print all trapped */
for (i = 0; i < NSIG; ++i) {
if (G.traps[i]) {
}
new_cmd = NULL;
- i = 0;
/* If first arg is a number: reset all specified signals */
sig = bb_strtou(*argv, NULL, 10);
if (errno == 0) {
if (sig < 0 || sig >= NSIG) {
ret = EXIT_FAILURE;
/* Mimic bash message exactly */
- bb_perror_msg("trap: %s: invalid signal specification", argv[i]);
+ bb_perror_msg("trap: %s: invalid signal specification", argv[-1]);
continue;
}
continue;
sigdelset(&G.blocked_set, sig);
}
- sigprocmask(SIG_SETMASK, &G.blocked_set, NULL);
}
+ sigprocmask(SIG_SETMASK, &G.blocked_set, NULL);
return ret;
}