[PATCH 01/10] hush: fix exit on syntax error behaviour
Sascha Hauer
s.hauer at pengutronix.de
Tue Nov 12 08:52:10 EST 2013
input.__promptme is no valid indicator that run_shell should be left.
It should be left on executing the 'exit' builtin which is indicated
by a return code < 0 from parse_stream_outer(). Track this with an extra
variable and use it as a condition to return from an interactive shell.
This fixes the weird behaviour that hush exits (and the user finds itself
in the menu) when a syntax error occured.
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
common/hush.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/common/hush.c b/common/hush.c
index bf1d9e6..5969127 100644
--- a/common/hush.c
+++ b/common/hush.c
@@ -1853,14 +1853,17 @@ int run_shell(void)
int rcode;
struct in_str input;
struct p_context ctx;
+ int exit = 0;
do {
setup_file_in_str(&input);
rcode = parse_stream_outer(&ctx, &input, FLAG_PARSE_SEMICOLON);
- if (rcode < -1)
+ if (rcode < -1) {
+ exit = 1;
rcode = -rcode - 2;
+ }
release_context(&ctx);
- } while (!input.__promptme);
+ } while (!exit);
return rcode;
}
--
1.8.4.2
More information about the barebox
mailing list