hush: fix "while false; ..." exitcode; add testsuites

This commit is contained in:
Denis Vlasenko 2008-07-28 23:17:31 +00:00
parent 6a2d40f239
commit 918a34b9e0
5 changed files with 24 additions and 1 deletions

View File

@ -2305,9 +2305,11 @@ static int run_list(struct pipe *pi)
#endif
#if ENABLE_HUSH_LOOPS
if (rword == RES_WHILE) {
if (rcode)
if (rcode) {
rcode = 0; /* "while false; do...done" - exitcode 0 */
goto check_jobs_and_break;
}
}
if (rword == RES_UNTIL) {
if (!rcode) {
check_jobs_and_break:

View File

@ -0,0 +1,6 @@
A
AA
TRUE
A
AA
OK:0

View File

@ -0,0 +1,12 @@
cond=true
while $cond; do
echo A
if test "$cond" = true; then
cond='echo TRUE'
else
cond=false
fi
while true; do echo AA; continue 2; echo BB; done
echo B
done
echo OK:$?

View File

@ -0,0 +1 @@
OK:0

View File

@ -0,0 +1,2 @@
while false; do echo NOT SHOWN; done
echo OK:$?