mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-01-01 05:16:05 +01:00
25409: fix eval's use of lastval
This commit is contained in:
parent
d026334a3b
commit
c4f33330f6
4 changed files with 47 additions and 7 deletions
|
@ -382,7 +382,10 @@ findex(eval)
|
|||
cindex(evaluating arguments as commands)
|
||||
item(tt(eval) [ var(arg) ... ])(
|
||||
Read the arguments as input to the shell and execute the resulting
|
||||
command in the current shell process.
|
||||
command(s) in the current shell process. The return status is the
|
||||
same as if the commands had been executed directly by the shell;
|
||||
if there are no var(args) or they contain no commands (i.e. are
|
||||
an empty string or whitespace) the return status is zero.
|
||||
)
|
||||
item(tt(exec) [ tt(-cl) ] [ tt(-a) var(argv0) ] var(simple command))(
|
||||
Replace the current shell with an external command rather than forking.
|
||||
|
|
|
@ -4717,17 +4717,19 @@ bin_eval(UNUSED(char *nam), char **argv, UNUSED(Options ops), UNUSED(int func))
|
|||
|
||||
prog = parse_string(zjoin(argv, ' ', 1));
|
||||
if (prog) {
|
||||
lastval = 0;
|
||||
if (wc_code(*prog->prog) != WC_LIST) {
|
||||
/* No code to execute */
|
||||
lastval = 0;
|
||||
} else {
|
||||
execode(prog, 1, 0);
|
||||
|
||||
execode(prog, 1, 0);
|
||||
|
||||
if (errflag)
|
||||
lastval = errflag;
|
||||
if (errflag)
|
||||
lastval = errflag;
|
||||
}
|
||||
} else {
|
||||
lastval = 1;
|
||||
}
|
||||
|
||||
|
||||
errflag = 0;
|
||||
scriptname = oscriptname;
|
||||
ineval = oineval;
|
||||
|
|
|
@ -11,6 +11,7 @@ B01cd.ztst
|
|||
B02typeset.ztst
|
||||
B03print.ztst
|
||||
B04read.ztst
|
||||
B05eval.ztst
|
||||
C01arith.ztst
|
||||
C02cond.ztst
|
||||
C03traps.ztst
|
||||
|
|
34
Test/B05eval.ztst
Normal file
34
Test/B05eval.ztst
Normal file
|
@ -0,0 +1,34 @@
|
|||
# Tests for the eval builtin.
|
||||
# This is quite short; eval is widely tested throughout the test suite
|
||||
# and its basic behaviour is fairly straightforward.
|
||||
|
||||
%prep
|
||||
|
||||
cmd='print $?'
|
||||
|
||||
%test
|
||||
|
||||
false
|
||||
eval $cmd
|
||||
0:eval retains value of $?
|
||||
>1
|
||||
|
||||
# no point getting worked up over what the error message is...
|
||||
./command_not_found 2>/dev/null
|
||||
eval $cmd
|
||||
0:eval after command not found
|
||||
>127
|
||||
|
||||
# trick the test system
|
||||
sp=
|
||||
false
|
||||
eval "
|
||||
$sp
|
||||
$sp
|
||||
$sp
|
||||
"
|
||||
0:eval with empty command resets the status
|
||||
|
||||
false
|
||||
eval
|
||||
0:eval with empty command resets the status
|
Loading…
Reference in a new issue