hush: fix another case where empty "for" wasn't setting exitcode to 0

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2018-07-28 12:42:08 +02:00
parent a8e7441176
commit a5db1d7354
5 changed files with 13 additions and 1 deletions

View File

@ -0,0 +1 @@
Zero:0

View File

@ -0,0 +1,5 @@
false
for v; do
exit 2
done
echo Zero:$?

View File

@ -9391,11 +9391,11 @@ static int run_list(struct pipe *pi)
}; /* argv list with one element: "$@" */ }; /* argv list with one element: "$@" */
char **vals; char **vals;
G.last_exitcode = rcode = EXIT_SUCCESS;
vals = (char**)encoded_dollar_at_argv; vals = (char**)encoded_dollar_at_argv;
if (pi->next->res_word == RES_IN) { if (pi->next->res_word == RES_IN) {
/* if no variable values after "in" we skip "for" */ /* if no variable values after "in" we skip "for" */
if (!pi->next->cmds[0].argv) { if (!pi->next->cmds[0].argv) {
G.last_exitcode = rcode = EXIT_SUCCESS;
debug_printf_exec(": null FOR: exitcode EXIT_SUCCESS\n"); debug_printf_exec(": null FOR: exitcode EXIT_SUCCESS\n");
break; break;
} }

View File

@ -0,0 +1 @@
Zero:0

View File

@ -0,0 +1,5 @@
false
for v; do
exit 2
done
echo Zero:$?