diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2017-01-03 11:47:50 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2017-01-10 16:55:51 +0100 |
commit | 9c806db4b744999213ddba755fff847d4525df9f (patch) | |
tree | 05e3a820dc21d637d82d3235eadc21ec8f34f3a9 | |
parent | 568cabf98a11e2e594243a309a9ffd7729a2b213 (diff) | |
download | busybox-w32-9c806db4b744999213ddba755fff847d4525df9f.tar.gz busybox-w32-9c806db4b744999213ddba755fff847d4525df9f.tar.bz2 busybox-w32-9c806db4b744999213ddba755fff847d4525df9f.zip |
hush: correct exitcode for unterminated ')' - exitcode2.tests testcase
function old new delta
parse_stream 2595 2609 +14
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | shell/hush.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/shell/hush.c b/shell/hush.c index fecc89294..a56d3b280 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
@@ -1137,6 +1137,9 @@ static void syntax_error_unexpected_ch(unsigned lineno UNUSED_PARAM, int ch) | |||
1137 | char msg[2]; | 1137 | char msg[2]; |
1138 | msg[0] = ch; | 1138 | msg[0] = ch; |
1139 | msg[1] = '\0'; | 1139 | msg[1] = '\0'; |
1140 | #if HUSH_DEBUG >= 2 | ||
1141 | bb_error_msg("hush.c:%u", lineno); | ||
1142 | #endif | ||
1140 | bb_error_msg("syntax error: unexpected %s", ch == EOF ? "EOF" : msg); | 1143 | bb_error_msg("syntax error: unexpected %s", ch == EOF ? "EOF" : msg); |
1141 | } | 1144 | } |
1142 | 1145 | ||
@@ -4997,7 +5000,8 @@ static struct pipe *parse_stream(char **pstring, | |||
4997 | * if we see {, we call parse_group(..., end_trigger='}') | 5000 | * if we see {, we call parse_group(..., end_trigger='}') |
4998 | * and it will match } earlier (not here). */ | 5001 | * and it will match } earlier (not here). */ |
4999 | syntax_error_unexpected_ch(ch); | 5002 | syntax_error_unexpected_ch(ch); |
5000 | goto parse_error; | 5003 | G.last_exitcode = 2; |
5004 | goto parse_error1; | ||
5001 | default: | 5005 | default: |
5002 | if (HUSH_DEBUG) | 5006 | if (HUSH_DEBUG) |
5003 | bb_error_msg_and_die("BUG: unexpected %c\n", ch); | 5007 | bb_error_msg_and_die("BUG: unexpected %c\n", ch); |
@@ -5005,6 +5009,8 @@ static struct pipe *parse_stream(char **pstring, | |||
5005 | } /* while (1) */ | 5009 | } /* while (1) */ |
5006 | 5010 | ||
5007 | parse_error: | 5011 | parse_error: |
5012 | G.last_exitcode = 1; | ||
5013 | parse_error1: | ||
5008 | { | 5014 | { |
5009 | struct parse_context *pctx; | 5015 | struct parse_context *pctx; |
5010 | IF_HAS_KEYWORDS(struct parse_context *p2;) | 5016 | IF_HAS_KEYWORDS(struct parse_context *p2;) |
@@ -5038,7 +5044,6 @@ static struct pipe *parse_stream(char **pstring, | |||
5038 | } while (HAS_KEYWORDS && pctx); | 5044 | } while (HAS_KEYWORDS && pctx); |
5039 | 5045 | ||
5040 | o_free(&dest); | 5046 | o_free(&dest); |
5041 | G.last_exitcode = 1; | ||
5042 | #if !BB_MMU | 5047 | #if !BB_MMU |
5043 | if (pstring) | 5048 | if (pstring) |
5044 | *pstring = NULL; | 5049 | *pstring = NULL; |