1
0
mirror of git://git.code.sf.net/p/zsh/code synced 2024-11-18 21:14:11 +01:00

17673: Fix bug with &&s and ||s in complex constructs

This commit is contained in:
Peter Stephenson 2002-09-17 10:42:17 +00:00
parent 49bfbc1248
commit 41b50445ea
3 changed files with 41 additions and 2 deletions

@ -1,3 +1,10 @@
2002-09-17 Peter Stephenson <pws@csr.com>
* 17673: Src/exec.c, Test/A01grammar.ztst:
for X in Y; true || B; done && X
executed X on every iteration. Same bug with true -> false,
|| -> &&, && -> ||.
2002-09-16 Oliver Kiddle <opk@zsh.org>
* 17678: Src/builtin.c: ignore initial `--' argument to printf

@ -851,8 +851,15 @@ execlist(Estate state, int dont_change_job, int exiting)
* for this sublist. */
donetrap = 1;
goto sublist_done;
} else if (WC_SUBLIST_TYPE(code) == WC_SUBLIST_END)
} else if (WC_SUBLIST_TYPE(code) == WC_SUBLIST_END) {
donetrap = 1;
/*
* Treat this in the same way as if we reached
* the end of the sublist normally.
*/
state->pc = next;
goto sublist_done;
}
}
cmdpush(CS_CMDAND);
break;
@ -877,8 +884,15 @@ execlist(Estate state, int dont_change_job, int exiting)
* for this sublist. */
donetrap = 1;
goto sublist_done;
} else if (WC_SUBLIST_TYPE(code) == WC_SUBLIST_END)
} else if (WC_SUBLIST_TYPE(code) == WC_SUBLIST_END) {
donetrap = 1;
/*
* Treat this in the same way as if we reached
* the end of the sublist normally.
*/
state->pc = next;
goto sublist_done;
}
}
cmdpush(CS_CMDOR);
break;

@ -319,3 +319,21 @@
done < /dev/null | { read name; print done }
0:Bug regression: `while' loop with redirection and pipeline
>done
# This used to be buggy and print X at the end of each iteration.
for f in 1 2 3 4; do
print $f || break
done && print X
0:Handling of ||'s and &&'s with a for loop in between
>1
>2
>3
>4
>X
# Same bug for &&, used to print `no' at the end of each iteration
for f in 1 2 3 4; do
false && print strange
done || print no
0:Handling of &&'s and ||'s with a for loop in between
>no