mirror of
git://git.code.sf.net/p/zsh/code
synced 2024-05-20 06:56:05 +02:00
zsh-users/21903: Fix ${...?...} in interactive shell.
On failure should abort back to top level, but we reset the error flag around commands. Add a hard error flag that's only reset at top level.
This commit is contained in:
parent
be4c072cf5
commit
a4b8ee13be
|
@ -1,3 +1,9 @@
|
|||
2016-09-14 Peter Stephenson <p.stephenson@samsung.com>
|
||||
|
||||
* zsh-users/21903: Src/subst.c, Src/zsh.h,
|
||||
Test/D04parameter.ztst: ${...?...} in interactive shell should
|
||||
abort to top level, not just current command.
|
||||
|
||||
2016-09-14 Marko Myllynen <myllynen@redhat.com>
|
||||
|
||||
* unposted: Completion/Unix/Command/_libvirt: Add another
|
||||
|
|
|
@ -2922,6 +2922,13 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags,
|
|||
if (isset(EXECOPT)) {
|
||||
*idend = '\0';
|
||||
zerr("%s: %s", idbeg, *s ? s : "parameter not set");
|
||||
/*
|
||||
* In interactive shell we need to return to
|
||||
* top-level prompt --- don't clear this error
|
||||
* after handling a command as we do with
|
||||
* most errors.
|
||||
*/
|
||||
errflag |= ERRFLAG_HARD;
|
||||
if (!interact) {
|
||||
if (mypid == getpid()) {
|
||||
/*
|
||||
|
|
|
@ -2807,7 +2807,14 @@ enum errflag_bits {
|
|||
/*
|
||||
* User interrupt.
|
||||
*/
|
||||
ERRFLAG_INT = 2
|
||||
ERRFLAG_INT = 2,
|
||||
/*
|
||||
* Hard error --- return to top-level prompt in interactive
|
||||
* shell. In non-interactive shell we'll typically already
|
||||
* have exited. This is reset by "errflag = 0" in
|
||||
* loop(toplevel = 1, ...).
|
||||
*/
|
||||
ERRFLAG_HARD = 4
|
||||
};
|
||||
|
||||
/***********/
|
||||
|
|
|
@ -95,6 +95,20 @@
|
|||
?(eval):1: unset1: exiting1
|
||||
?(eval):2: null1: exiting2
|
||||
|
||||
PROMPT="" $ZTST_testdir/../Src/zsh -fis <<<'
|
||||
unsetopt PROMPT_SP
|
||||
PS2="" PS3="" PS4="" RPS1="" RPS2=""
|
||||
foo() {
|
||||
print ${1:?no arguments given}
|
||||
print not reached
|
||||
}
|
||||
foo
|
||||
print reached
|
||||
'
|
||||
0:interactive shell returns to top level on ${...?...} error
|
||||
?foo:1: 1: no arguments given
|
||||
>reached
|
||||
|
||||
print ${set1:+word1} ${set1+word2} ${null1:+word3} ${null1+word4}
|
||||
print ${unset1:+word5} ${unset1+word6}
|
||||
0:${...:+...}, ${...+...}
|
||||
|
|
Loading…
Reference in New Issue