1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-11 13:01:28 +02:00

27126: a few more contexts where executing empty lists gives status zero

This commit is contained in:
Peter Stephenson 2009-07-10 22:10:25 +00:00
parent b4c2ea2cec
commit 4db28c55b6
6 changed files with 51 additions and 2 deletions

View file

@ -1,5 +1,9 @@
2009-07-10 Peter Stephenson <p.w.stephenson@ntlworld.com>
* 27126: Src/exec.c, Src/init.c, Test/A01grammar.ztst,
Test/C04funcdef.ztst, Test/D08cmdsubst.ztst: a few more
contexts where empty lists should give status zero.
* 27125: Src/prompt.c: handle nested use of colour code buffer
allocation.
@ -11950,5 +11954,5 @@
*****************************************************
* This is used by the shell to define $ZSH_PATCHLEVEL
* $Revision: 1.4734 $
* $Revision: 1.4735 $
*****************************************************

View file

@ -1372,7 +1372,8 @@ execpline(Estate state, wordcode slcode, int how, int last1)
else
spawnjob();
child_unblock();
return 0;
/* Executing background code resets shell status */
return lastval = 0;
} else {
if (newjob != lastwj) {
Job jn = jobtab + newjob;
@ -3512,6 +3513,7 @@ getoutput(char *cmd, int qt)
return retval;
}
/* pid == 0 */
lastval = 0; /* status of empty list is zero */
child_unblock();
zclose(pipes[0]);
redup(pipes[1], 1);
@ -4259,6 +4261,7 @@ doshfunc(Shfunc shfunc, LinkList doshargs, int noreturnval)
if (trap_state == TRAP_STATE_PRIMED)
trap_return--;
oldlastval = lastval;
lastval = 0; /* status of empty function is zero */
oldnumpipestats = numpipestats;
if (noreturnval) {
/*

View file

@ -1131,6 +1131,7 @@ source(char *s)
fstack.tp = FS_SOURCE;
funcstack = &fstack;
lastval = 0; /* status of empty file is zero */
if (prog) {
pushheap();
errflag = 0;

View file

@ -27,6 +27,18 @@
$nonexistent_variable
0:Executing command that evaluates to empty resets status
false
sleep 1 &
print $?
# a tidy test is a happy test
wait $!
0:Starting background command resets status
>0
false
. /dev/null
0:Sourcing empty file resets status
fn() { local foo; read foo; print $foo; }
coproc fn
print -p coproc test output
@ -531,3 +543,13 @@
. ./bad_syntax
126: Attempt to "." file with bad syntax.
?./bad_syntax:2: parse error near `\n'
echo 'false' >dot_false
. ./dot_false
print $?
echo 'true' >dot_true
. ./dot_true
print $?
0:Last status of successfully executed "." file is retained
>1
>0

View file

@ -1,5 +1,20 @@
%test
fn1() { return 1; }
fn2() {
fn1
print $?
return 2
}
fn2
2:Basic status returns from functions
>1
fnz() { }
false
fnz
0:Empty function body resets status
function f$$ () {
print regress expansion of function names
}

View file

@ -89,3 +89,7 @@
X=$(exit 2) $(exit 0) || print $?
0:variable assignments processed after other substitutions
>2
false
``
0:Empty command substitution resets status