Skip to contentSkip to conversation

hush exit code fix

PATCH In review Jan Weitzel 2 participants 2 messages Mar 5, 2010 – Mar 12, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hush exit code fix

hush: pass return code from exit command within if statement

---

common/hush.c +2 -3
index cf6704b..ae09374 100644
@@ -535,10 +535,9 @@ static int run_pipe_real(struct pipe *pi)
        if (pi->num_progs == 1)
                child = & (pi->progs[0]);
        if (pi->num_progs == 1 && child->group) {
-               int rcode;
                debug("non-subshell grouping\n");
-               rcode = run_list_real(child->group);
-               return rcode;
+               run_list_real(child->group);
+               return last_return_code;
        } else if (pi->num_progs == 1 && pi->progs[0].argv != NULL) {
                for (i=0; is_assignment(child->argv[i]); i++) { /* nothing */ }
                if (i!=0 && child->argv[i]==NULL) {

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#1 lore raw

Hi Jan,

Quoted 14 lines · Jan Weitzel

hush: pass return code from exit command within if statement

---

common/hush.c +0 -0
index cf6704b..ae09374 100644
@@ -535,10 +535,9 @@ static int run_pipe_real(struct pipe *pi)
        if (pi->num_progs == 1)
                child = & (pi->progs[0]);

common/hush.c static int run_pipe_real(struct pipe *pi) · line 543

Quoted 10 lines
common/hush.c +2 -3
        if (pi->num_progs == 1 && child->group) {
-               int rcode;
                debug("non-subshell grouping\n");
-               rcode = run_list_real(child->group);
-               return rcode;
+               run_list_real(child->group);
+               return last_return_code;
        } else if (pi->num_progs == 1 && pi->progs[0].argv != NULL) {
                for (i=0; is_assignment(child->argv[i]); i++) { /* nothing */ }
                if (i!=0 && child->argv[i]==NULL) {

This does not solve the problem and introduces a new one:

barebox:/ cat /env/bin/bar
false
if [ $? != 0 ]; then
echo tschuess
exit
fi

echo hallo

barebox:/ bar
tschuess
hallo
barebox:/

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox