1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-15 02:11:07 +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> 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 * 27125: Src/prompt.c: handle nested use of colour code buffer
allocation. allocation.
@ -11950,5 +11954,5 @@
***************************************************** *****************************************************
* This is used by the shell to define $ZSH_PATCHLEVEL * 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 else
spawnjob(); spawnjob();
child_unblock(); child_unblock();
return 0; /* Executing background code resets shell status */
return lastval = 0;
} else { } else {
if (newjob != lastwj) { if (newjob != lastwj) {
Job jn = jobtab + newjob; Job jn = jobtab + newjob;
@ -3512,6 +3513,7 @@ getoutput(char *cmd, int qt)
return retval; return retval;
} }
/* pid == 0 */ /* pid == 0 */
lastval = 0; /* status of empty list is zero */
child_unblock(); child_unblock();
zclose(pipes[0]); zclose(pipes[0]);
redup(pipes[1], 1); redup(pipes[1], 1);
@ -4259,6 +4261,7 @@ doshfunc(Shfunc shfunc, LinkList doshargs, int noreturnval)
if (trap_state == TRAP_STATE_PRIMED) if (trap_state == TRAP_STATE_PRIMED)
trap_return--; trap_return--;
oldlastval = lastval; oldlastval = lastval;
lastval = 0; /* status of empty function is zero */
oldnumpipestats = numpipestats; oldnumpipestats = numpipestats;
if (noreturnval) { if (noreturnval) {
/* /*

View file

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

View file

@ -27,6 +27,18 @@
$nonexistent_variable $nonexistent_variable
0:Executing command that evaluates to empty resets status 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; } fn() { local foo; read foo; print $foo; }
coproc fn coproc fn
print -p coproc test output print -p coproc test output
@ -531,3 +543,13 @@
. ./bad_syntax . ./bad_syntax
126: Attempt to "." file with bad syntax. 126: Attempt to "." file with bad syntax.
?./bad_syntax:2: parse error near `\n' ?./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 %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$$ () { function f$$ () {
print regress expansion of function names print regress expansion of function names
} }

View file

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