Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: traps specified in certain ways are output incorrectly



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.



Messages sorted by: Reverse Date, Date, Thread, Author