hush: non-matching "case" statement sets $? to 0
authorDenys Vlasenko <vda.linux@googlemail.com>
Fri, 4 Nov 2016 17:52:48 +0000 (18:52 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Fri, 4 Nov 2016 17:52:48 +0000 (18:52 +0100)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
shell/hush.c

index 336de75adc371ff1009649b1f797207d29e1967a..4c2ed6cead72ba0e9f081ef39f758ff043bb0ea9 100644 (file)
@@ -7874,6 +7874,8 @@ static int run_list(struct pipe *pi)
 #endif
 #if ENABLE_HUSH_CASE
                if (rword == RES_CASE) {
+                       /* Case which does not match and execute anything still sets $? to 0 */
+                       G.last_exitcode = rcode = EXIT_SUCCESS;
                        case_word = expand_strvec_to_string(pi->cmds->argv);
                        continue;
                }