@@ -259,7 +259,7 @@ usage:
}
if (**++argv == '-') {
- signo = decode_signal(*argv + 1, 1);
+ signo = decode_signal(*argv + 1, 1, 0);
if (signo < 0) {
int c;
@@ -273,7 +273,7 @@ usage:
list = 1;
break;
case 's':
- signo = decode_signal(optionarg, 1);
+ signo = decode_signal(optionarg, 1, 0);
if (signo < 0) {
sh_error(
"invalid signal number or name: %s",
@@ -112,12 +112,12 @@ trapcmd(int argc, char **argv)
}
return 0;
}
- if (!ap[1])
+ if ((!ap[1]) || (decode_signal(*ap, 0, 1)) >= 0)
action = NULL;
else
action = *ap++;
while (*ap) {
- if ((signo = decode_signal(*ap, 0)) < 0) {
+ if ((signo = decode_signal(*ap, 0, 0)) < 0) {
outfmt(out2, "trap: %s: bad trap\n", *ap);
return 1;
}
@@ -400,7 +400,7 @@ out:
/* NOTREACHED */
}
-int decode_signal(const char *string, int minsig)
+int decode_signal(const char *string, int minsig, int numonly)
{
int signo;
@@ -410,7 +410,8 @@ int decode_signal(const char *string, int minsig)
return -1;
}
return signo;
- }
+ } else if (numonly)
+ return -1;
for (signo = minsig; signo < NSIG; signo++) {
if (!strcasecmp(string, signal_names[signo])) {
@@ -49,7 +49,7 @@ void onsig(int);
void dotrap(void);
void setinteractive(int);
void exitshell(void) __attribute__((__noreturn__));
-int decode_signal(const char *, int);
+int decode_signal(const char *, int, int);
static inline int have_traps(void)
{