← Commit list

00ae989ee

Denys Vlasenko
Denys Vlasenko
2011-05-31
FAILED Duration: 222s

Subject

hush: fix a corner case of empty "do \n done" structure

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

shell/hush.c+4 -1
@@ -7498,7 +7498,10 @@ static int run_list(struct pipe *pi)
#endif
#if ENABLE_HUSH_LOOPS
/* Beware of "while false; true; do ..."! */
- if (pi->next && pi->next->res_word == RES_DO) {
+ if (pi->next
+ && (pi->next->res_word == RES_DO || pi->next->res_word == RES_DONE)
+ /* (the second check above is needed for "while ...; do \n done" case) */
+ ) {
if (rword == RES_WHILE) {
if (rcode) {
/* "while false; do...done" - exitcode 0 */
shell/hush_test/hush-misc/while3.right+1 -0
@@ -0,0 +1 @@
+OK:0
shell/hush_test/hush-misc/while3.tests+4 -0
@@ -0,0 +1,4 @@
+while false; do
+ # bash will require at least ":" here...
+done
+echo OK:$?