sh: Don't modify exit status when break/continue/return passes !.
This matches what would happen if ! P were to be replaced with if P; then false; else true; fi. Example: f() { ! return 0; }; f
This commit is contained in:
parent
1a47f28b71
commit
6e0f89a4b4
@ -279,6 +279,8 @@ evaltree(union node *n, int flags)
|
||||
break;
|
||||
case NNOT:
|
||||
evaltree(n->nnot.com, EV_TESTED);
|
||||
if (evalskip)
|
||||
goto out;
|
||||
exitstatus = !exitstatus;
|
||||
break;
|
||||
|
||||
|
4
tools/regression/bin/sh/execution/not1.0
Normal file
4
tools/regression/bin/sh/execution/not1.0
Normal file
@ -0,0 +1,4 @@
|
||||
# $FreeBSD$
|
||||
|
||||
f() { ! return $1; }
|
||||
f 0 && ! f 1
|
6
tools/regression/bin/sh/execution/not2.0
Normal file
6
tools/regression/bin/sh/execution/not2.0
Normal file
@ -0,0 +1,6 @@
|
||||
# $FreeBSD$
|
||||
|
||||
while :; do
|
||||
! break
|
||||
exit 3
|
||||
done
|
Loading…
Reference in New Issue
Block a user