summaryrefslogtreecommitdiff
path: root/Src
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2002-12-04 13:57:48 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2002-12-04 13:57:48 +0000
commit28a62d5a4ba6a7eb8361583ad0f6f5b32e1a0ee9 (patch)
tree114fbfdf69dc40dd86a029573f22b86ead2dfe81 /Src
parent252da01c87086db05083be7e66804e28fcf50c89 (diff)
downloadzsh-28a62d5a4ba6a7eb8361583ad0f6f5b32e1a0ee9.tar.gz
zsh-28a62d5a4ba6a7eb8361583ad0f6f5b32e1a0ee9.zip
17979: Add ERR_RETURN option.
Diffstat (limited to 'Src')
-rw-r--r--Src/exec.c24
-rw-r--r--Src/options.c1
-rw-r--r--Src/zsh.h1
3 files changed, 19 insertions, 7 deletions
diff --git a/Src/exec.c b/Src/exec.c
index ca7b2061f..76ca437f4 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -924,13 +924,23 @@ sublist_done:
dotrap(SIGZERR);
donetrap = 1;
}
- if (lastval && isset(ERREXIT)) {
- if (sigtrapped[SIGEXIT])
- dotrap(SIGEXIT);
- if (mypid != getpid())
- _exit(lastval);
- else
- exit(lastval);
+ if (lastval) {
+ int errreturn = isset(ERRRETURN) &&
+ (isset(INTERACTIVE) || locallevel || sourcelevel);
+ int errexit = isset(ERREXIT) ||
+ (isset(ERRRETURN) && !errreturn);
+ if (errexit) {
+ if (sigtrapped[SIGEXIT])
+ dotrap(SIGEXIT);
+ if (mypid != getpid())
+ _exit(lastval);
+ else
+ exit(lastval);
+ }
+ if (errreturn) {
+ retflag = 1;
+ breaks = loops;
+ }
}
}
if (ltype & Z_END)
diff --git a/Src/options.c b/Src/options.c
index 841a3cb82..da1e9efac 100644
--- a/Src/options.c
+++ b/Src/options.c
@@ -109,6 +109,7 @@ static struct optname optns[] = {
{NULL, "cshnullglob", OPT_EMULATE|OPT_CSH, CSHNULLGLOB},
{NULL, "equals", OPT_EMULATE|OPT_ZSH, EQUALS},
{NULL, "errexit", OPT_EMULATE, ERREXIT},
+{NULL, "errreturn", OPT_EMULATE, ERRRETURN},
{NULL, "exec", OPT_ALL, EXECOPT},
{NULL, "extendedglob", OPT_EMULATE, EXTENDEDGLOB},
{NULL, "extendedhistory", OPT_CSH, EXTENDEDHISTORY},
diff --git a/Src/zsh.h b/Src/zsh.h
index 62136719a..9d402b242 100644
--- a/Src/zsh.h
+++ b/Src/zsh.h
@@ -1419,6 +1419,7 @@ enum {
CSHNULLGLOB,
EQUALS,
ERREXIT,
+ ERRRETURN,
EXECOPT,
EXTENDEDGLOB,
EXTENDEDHISTORY,