summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
Diffstat (limited to 'Src')
-rw-r--r--Src/options.c1
-rw-r--r--Src/signals.c10
-rw-r--r--Src/zsh.h1
3 files changed, 8 insertions, 4 deletions
diff --git a/Src/options.c b/Src/options.c
index dedbf0c73..02b471925 100644
--- a/Src/options.c
+++ b/Src/options.c
@@ -204,6 +204,7 @@ static struct optname optns[] = {
 {{NULL, "posixcd",            OPT_EMULATE|OPT_BOURNE},	 POSIXCD},
 {{NULL, "posixidentifiers",   OPT_EMULATE|OPT_BOURNE},	 POSIXIDENTIFIERS},
 {{NULL, "posixjobs",          OPT_EMULATE|OPT_BOURNE},	 POSIXJOBS},
+{{NULL, "posixtraps",          OPT_EMULATE|OPT_BOURNE},	 POSIXTRAPS},
 {{NULL, "printeightbit",      0},                        PRINTEIGHTBIT},
 {{NULL, "printexitvalue",     0},			 PRINTEXITVALUE},
 {{NULL, "privileged",	      OPT_SPECIAL},		 PRIVILEGED},
diff --git a/Src/signals.c b/Src/signals.c
index 49e5e6379..d107b46d1 100644
--- a/Src/signals.c
+++ b/Src/signals.c
@@ -864,7 +864,8 @@ removetrap(int sig)
      * one, to aid in removing this one.  However, if there's
      * already one at the current locallevel we just overwrite it.
      */
-    if (!dontsavetrap && (isset(LOCALTRAPS) || sig == SIGEXIT) &&
+    if (!dontsavetrap &&
+	(sig == SIGEXIT ? !isset(POSIXTRAPS) : isset(LOCALTRAPS)) &&
 	locallevel &&
 	(!trapped || locallevel > (sigtrapped[sig] >> ZSIG_SHIFT)))
 	dosavetrap(sig, locallevel);
@@ -932,7 +933,7 @@ starttrapscope(void)
      * so give it the next higher one. dosavetrap() is called
      * automatically where necessary.
      */
-    if (sigtrapped[SIGEXIT]) {
+    if (sigtrapped[SIGEXIT] && !isset(POSIXTRAPS)) {
 	locallevel++;
 	unsettrap(SIGEXIT);
 	locallevel--;
@@ -960,7 +961,7 @@ endtrapscope(void)
      */
     if (intrap)
 	exittr = 0;
-    else if ((exittr = sigtrapped[SIGEXIT])) {
+    else if (!isset(POSIXTRAPS) && (exittr = sigtrapped[SIGEXIT])) {
 	if (exittr & ZSIG_FUNC) {
 	    exitfn = removehashnode(shfunctab, "TRAPEXIT");
 	} else {
@@ -1005,7 +1006,8 @@ endtrapscope(void)
     }
 
     if (exittr) {
-	dotrapargs(SIGEXIT, &exittr, exitfn);
+	if (!isset(POSIXTRAPS))
+	    dotrapargs(SIGEXIT, &exittr, exitfn);
 	if (exittr & ZSIG_FUNC)
 	    shfunctab->freenode((HashNode)exitfn);
 	else
diff --git a/Src/zsh.h b/Src/zsh.h
index 77281aa75..a825a6bab 100644
--- a/Src/zsh.h
+++ b/Src/zsh.h
@@ -1987,6 +1987,7 @@ enum {
     POSIXCD,
     POSIXIDENTIFIERS,
     POSIXJOBS,
+    POSIXTRAPS,
     PRINTEIGHTBIT,
     PRINTEXITVALUE,
     PRIVILEGED,