diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-07-28 23:17:31 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-07-28 23:17:31 +0000 |
commit | 918a34b9e04cbf368dd7a1116d7467e6e7f8ccc9 (patch) | |
tree | e210dcb9b76b230df380c56334f9a26d6f0aa05e | |
parent | 6a2d40f239566e886ef76542a75662cee9380a0e (diff) | |
download | busybox-w32-918a34b9e04cbf368dd7a1116d7467e6e7f8ccc9.tar.gz busybox-w32-918a34b9e04cbf368dd7a1116d7467e6e7f8ccc9.tar.bz2 busybox-w32-918a34b9e04cbf368dd7a1116d7467e6e7f8ccc9.zip |
hush: fix "while false; ..." exitcode; add testsuites
-rw-r--r-- | shell/hush.c | 4 | ||||
-rw-r--r-- | shell/hush_test/hush-misc/break4.right | 6 | ||||
-rwxr-xr-x | shell/hush_test/hush-misc/break4.tests | 12 | ||||
-rw-r--r-- | shell/hush_test/hush-misc/while1.right | 1 | ||||
-rwxr-xr-x | shell/hush_test/hush-misc/while1.tests | 2 |
5 files changed, 24 insertions, 1 deletions
diff --git a/shell/hush.c b/shell/hush.c index a74fe4730..5b2f188cd 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
@@ -2305,8 +2305,10 @@ static int run_list(struct pipe *pi) | |||
2305 | #endif | 2305 | #endif |
2306 | #if ENABLE_HUSH_LOOPS | 2306 | #if ENABLE_HUSH_LOOPS |
2307 | if (rword == RES_WHILE) { | 2307 | if (rword == RES_WHILE) { |
2308 | if (rcode) | 2308 | if (rcode) { |
2309 | rcode = 0; /* "while false; do...done" - exitcode 0 */ | ||
2309 | goto check_jobs_and_break; | 2310 | goto check_jobs_and_break; |
2311 | } | ||
2310 | } | 2312 | } |
2311 | if (rword == RES_UNTIL) { | 2313 | if (rword == RES_UNTIL) { |
2312 | if (!rcode) { | 2314 | if (!rcode) { |
diff --git a/shell/hush_test/hush-misc/break4.right b/shell/hush_test/hush-misc/break4.right new file mode 100644 index 000000000..6f41c141d --- /dev/null +++ b/shell/hush_test/hush-misc/break4.right | |||
@@ -0,0 +1,6 @@ | |||
1 | A | ||
2 | AA | ||
3 | TRUE | ||
4 | A | ||
5 | AA | ||
6 | OK:0 | ||
diff --git a/shell/hush_test/hush-misc/break4.tests b/shell/hush_test/hush-misc/break4.tests new file mode 100755 index 000000000..67da2889c --- /dev/null +++ b/shell/hush_test/hush-misc/break4.tests | |||
@@ -0,0 +1,12 @@ | |||
1 | cond=true | ||
2 | while $cond; do | ||
3 | echo A | ||
4 | if test "$cond" = true; then | ||
5 | cond='echo TRUE' | ||
6 | else | ||
7 | cond=false | ||
8 | fi | ||
9 | while true; do echo AA; continue 2; echo BB; done | ||
10 | echo B | ||
11 | done | ||
12 | echo OK:$? | ||
diff --git a/shell/hush_test/hush-misc/while1.right b/shell/hush_test/hush-misc/while1.right new file mode 100644 index 000000000..7c4d7beb0 --- /dev/null +++ b/shell/hush_test/hush-misc/while1.right | |||
@@ -0,0 +1 @@ | |||
OK:0 | |||
diff --git a/shell/hush_test/hush-misc/while1.tests b/shell/hush_test/hush-misc/while1.tests new file mode 100755 index 000000000..11e201e6a --- /dev/null +++ b/shell/hush_test/hush-misc/while1.tests | |||
@@ -0,0 +1,2 @@ | |||
1 | while false; do echo NOT SHOWN; done | ||
2 | echo OK:$? | ||