Commit 587e1d43e786ad70ce52a47f74b98d785098e378
Committed by
Tom Rini
1 parent
c9bcb6f13d
Exists in
v2017.01-smarct4x
and in
40 other branches
Fix hush to give the correct return code for a simple command
When a simple command like 'false' is provided, hush should return the result of that command. However, hush only does this if the FLAG_EXIT_FROM_LOOP flag is provided. Without this flag, hush will happily execute the empty string command immediate after 'false' and then return a success code. This behaviour does not seem very useful, and requiring the flag also seems wrong, since it means that hush will execute only the first command in a sequence. Add a check for empty string and fall out of the loop in that case. That at least fixes the simple command case. This is a change in behaviour but it is unlikely that the old behaviour would be considered correct in any case. Reported-by: Stefan Herbrechtsmeier <stefan@herbrechtsmeier.net> Signed-off-by: Simon Glass <sjg@chromium.org>
Showing 1 changed file with 3 additions and 1 deletions Side-by-side Diff
common/cli_hush.c
... | ... | @@ -3215,7 +3215,9 @@ |
3215 | 3215 | free_pipe_list(ctx.list_head,0); |
3216 | 3216 | } |
3217 | 3217 | b_free(&temp); |
3218 | - } while (rcode != -1 && !(flag & FLAG_EXIT_FROM_LOOP)); /* loop on syntax errors, return on EOF */ | |
3218 | + /* loop on syntax errors, return on EOF */ | |
3219 | + } while (rcode != -1 && !(flag & FLAG_EXIT_FROM_LOOP) && | |
3220 | + (inp->peek != static_peek || b_peek(inp))); | |
3219 | 3221 | #ifndef __U_BOOT__ |
3220 | 3222 | return 0; |
3221 | 3223 | #else |