* Re: traps specified in certain ways are output incorrectly
2015-08-05 20:51 traps specified in certain ways are output incorrectly Mikael Magnusson
@ 2015-08-06 20:31 ` Daniel Shahaf
0 siblings, 0 replies; 2+ messages in thread
From: Daniel Shahaf @ 2015-08-06 20:31 UTC (permalink / raw)
To: Mikael Magnusson; +Cc: zsh workers
Mikael Magnusson wrote on Wed, Aug 05, 2015 at 22:51:51 +0200:
> % trap a TERM; trap b SIGKILL; trap c 14; trap
> Bad alias flag for signal
> Bad alias flag for signal
> trap -- b
> trap -- c
> trap -- a TERM
>
> (The alias flag message is only printed with --enable-zsh-debug).
This makes it DTRT:
diff --git a/Src/builtin.c b/Src/builtin.c
index a08a7d4..34bad03 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -6565,8 +6565,14 @@ bin_trap(char *name, char **argv, UNUSED(Options ops), UNUSED(int func))
zwarnnam(name, "undefined signal: %s", *argv);
break;
}
- if (!strcmp(sigs[sig], *argv))
+ if (idigit(**argv) ||
+ !strcmp(sigs[sig], *argv) ||
+ (!strncmp("SIG", *argv, 3) && !strcmp(sigs[sig], *argv+3))) {
+ /* The signal was specified by number or by canonical name (with
+ * or without SIG prefix).
+ */
flags = 0;
+ }
else {
/*
* Record that the signal is used under an assumed name.
^ permalink raw reply [flat|nested] 2+ messages in thread