aboutsummaryrefslogtreecommitdiff
path: root/shell/ash.c
diff options
context:
space:
mode:
Diffstat (limited to 'shell/ash.c')
-rw-r--r--shell/ash.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/shell/ash.c b/shell/ash.c
index b4b0d5253..42e14cbc8 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;