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:
Jilles Tjoelker 2013-04-12 15:19:35 +00:00
parent 1a47f28b71
commit 6e0f89a4b4
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=249407
3 changed files with 12 additions and 0 deletions

View File

@ -279,6 +279,8 @@ evaltree(union node *n, int flags)
break; break;
case NNOT: case NNOT:
evaltree(n->nnot.com, EV_TESTED); evaltree(n->nnot.com, EV_TESTED);
if (evalskip)
goto out;
exitstatus = !exitstatus; exitstatus = !exitstatus;
break; break;

View File

@ -0,0 +1,4 @@
# $FreeBSD$
f() { ! return $1; }
f 0 && ! f 1

View File

@ -0,0 +1,6 @@
# $FreeBSD$
while :; do
! break
exit 3
done