mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-26 18:01:03 +02:00
17979: Add ERR_RETURN option.
This commit is contained in:
parent
252da01c87
commit
28a62d5a4b
5 changed files with 34 additions and 7 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2002-12-04 Peter Stephenson <pws@csr.com>
|
||||||
|
|
||||||
|
* 17979: Doc/Zsh/options.yo, Src/exec.c, Src/options.c, Src/zsh.h:
|
||||||
|
Add ERR_RETURN option, similiar to ERR_EXIT option.
|
||||||
|
|
||||||
2002-11-26 Peter Stephenson <pws@csr.com>
|
2002-11-26 Peter Stephenson <pws@csr.com>
|
||||||
|
|
||||||
* 17967: Test/B02typeset.ztst: globbable arguments to
|
* 17967: Test/B02typeset.ztst: globbable arguments to
|
||||||
|
|
|
@ -380,6 +380,16 @@ If a command has a non-zero exit status, execute the tt(ZERR)
|
||||||
trap, if set, and exit. This is disabled while running initialization
|
trap, if set, and exit. This is disabled while running initialization
|
||||||
scripts.
|
scripts.
|
||||||
)
|
)
|
||||||
|
pindex(ERR_RETURN)
|
||||||
|
cindex(function return, on error)
|
||||||
|
cidnex(return from function, on error)
|
||||||
|
item(tt(ERR_RETURN))(
|
||||||
|
If a command has a non-zero exit status, return immediately from the
|
||||||
|
enclosing function. The logic is identical to that for tt(ERR_EXIT),
|
||||||
|
except that an implicit tt(return) statement is executed instead of an
|
||||||
|
tt(exit). This will trigger an exit at the outermost level of a
|
||||||
|
non-interactive script.
|
||||||
|
)
|
||||||
pindex(EXEC)
|
pindex(EXEC)
|
||||||
cindex(command execution, enabling)
|
cindex(command execution, enabling)
|
||||||
item(tt(EXEC) (tt(PLUS()n), ksh: tt(PLUS()n)) <D>)(
|
item(tt(EXEC) (tt(PLUS()n), ksh: tt(PLUS()n)) <D>)(
|
||||||
|
|
12
Src/exec.c
12
Src/exec.c
|
@ -924,7 +924,12 @@ sublist_done:
|
||||||
dotrap(SIGZERR);
|
dotrap(SIGZERR);
|
||||||
donetrap = 1;
|
donetrap = 1;
|
||||||
}
|
}
|
||||||
if (lastval && isset(ERREXIT)) {
|
if (lastval) {
|
||||||
|
int errreturn = isset(ERRRETURN) &&
|
||||||
|
(isset(INTERACTIVE) || locallevel || sourcelevel);
|
||||||
|
int errexit = isset(ERREXIT) ||
|
||||||
|
(isset(ERRRETURN) && !errreturn);
|
||||||
|
if (errexit) {
|
||||||
if (sigtrapped[SIGEXIT])
|
if (sigtrapped[SIGEXIT])
|
||||||
dotrap(SIGEXIT);
|
dotrap(SIGEXIT);
|
||||||
if (mypid != getpid())
|
if (mypid != getpid())
|
||||||
|
@ -932,6 +937,11 @@ sublist_done:
|
||||||
else
|
else
|
||||||
exit(lastval);
|
exit(lastval);
|
||||||
}
|
}
|
||||||
|
if (errreturn) {
|
||||||
|
retflag = 1;
|
||||||
|
breaks = loops;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (ltype & Z_END)
|
if (ltype & Z_END)
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -109,6 +109,7 @@ static struct optname optns[] = {
|
||||||
{NULL, "cshnullglob", OPT_EMULATE|OPT_CSH, CSHNULLGLOB},
|
{NULL, "cshnullglob", OPT_EMULATE|OPT_CSH, CSHNULLGLOB},
|
||||||
{NULL, "equals", OPT_EMULATE|OPT_ZSH, EQUALS},
|
{NULL, "equals", OPT_EMULATE|OPT_ZSH, EQUALS},
|
||||||
{NULL, "errexit", OPT_EMULATE, ERREXIT},
|
{NULL, "errexit", OPT_EMULATE, ERREXIT},
|
||||||
|
{NULL, "errreturn", OPT_EMULATE, ERRRETURN},
|
||||||
{NULL, "exec", OPT_ALL, EXECOPT},
|
{NULL, "exec", OPT_ALL, EXECOPT},
|
||||||
{NULL, "extendedglob", OPT_EMULATE, EXTENDEDGLOB},
|
{NULL, "extendedglob", OPT_EMULATE, EXTENDEDGLOB},
|
||||||
{NULL, "extendedhistory", OPT_CSH, EXTENDEDHISTORY},
|
{NULL, "extendedhistory", OPT_CSH, EXTENDEDHISTORY},
|
||||||
|
|
|
@ -1419,6 +1419,7 @@ enum {
|
||||||
CSHNULLGLOB,
|
CSHNULLGLOB,
|
||||||
EQUALS,
|
EQUALS,
|
||||||
ERREXIT,
|
ERREXIT,
|
||||||
|
ERRRETURN,
|
||||||
EXECOPT,
|
EXECOPT,
|
||||||
EXTENDEDGLOB,
|
EXTENDEDGLOB,
|
||||||
EXTENDEDHISTORY,
|
EXTENDEDHISTORY,
|
||||||
|
|
Loading…
Reference in a new issue