about summary refs log tree commit diff
path: root/Src/builtin.c
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2005-06-01 10:45:32 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2005-06-01 10:45:32 +0000
commit772007e76c430588b0b0a234e4db90e5ad50293d (patch)
tree2cab428a1c72d496435e885a9b6a889e4516c529 /Src/builtin.c
parent9f63db611a8ee2becff902949398447fd55dfccc (diff)
downloadzsh-772007e76c430588b0b0a234e4db90e5ad50293d.tar.gz
zsh-772007e76c430588b0b0a234e4db90e5ad50293d.tar.xz
zsh-772007e76c430588b0b0a234e4db90e5ad50293d.zip
21296: Add ERR alias for ZERR where possible.
"trap" reports alias names.
Diffstat (limited to 'Src/builtin.c')
-rw-r--r--Src/builtin.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/Src/builtin.c b/Src/builtin.c
index 09034c514..69d78c926 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -4978,13 +4978,14 @@ bin_trap(char *name, char **argv, UNUSED(Options ops), UNUSED(int func))
 		    shfunctab->printnode(hn, 0);
 		DPUTS(!hn, "BUG: I did not find any trap functions!");
 	    } else if (sigtrapped[sig]) {
+		char *name = getsigname(sig);
 		if (!siglists[sig])
-		    printf("trap -- '' %s\n", sigs[sig]);
+		    printf("trap -- '' %s\n", name);
 		else {
 		    s = getpermtext(siglists[sig], NULL);
 		    printf("trap -- ");
 		    quotedzputs(s, stdout);
-		    printf(" %s\n", sigs[sig]);
+		    printf(" %s\n", name);
 		    zsfree(s);
 		}
 	    }
@@ -5017,14 +5018,25 @@ bin_trap(char *name, char **argv, UNUSED(Options ops), UNUSED(int func))
     /* set traps */
     for (; *argv; argv++) {
 	Eprog t;
+	int flags;
 
 	sig = getsignum(*argv);
 	if (sig == -1) {
 	    zwarnnam(name, "undefined signal: %s", *argv, 0);
 	    break;
 	}
+	if (!strcmp(sigs[sig], *argv))
+	    flags = 0;
+	else {
+	    /*
+	     * Record that the signal is used under an assumed name.
+	     * If we ever have more than one alias per signal this
+	     * will need improving.
+	     */
+	    flags = ZSIG_ALIAS;
+	}
 	t = dupeprog(prog, 0);
-	if (settrap(sig, t, 0))
+	if (settrap(sig, t, flags))
 	    freeeprog(t);
     }
     return *argv != NULL;