hush: Only run list if it's not empty
PATCH 1/2 hush: Only run list if it's not empty
Running empty lists causes wrong return status
Adapted from Barebox commit 4596d2b
Author: Sascha Hauer <[email protected]> Date: Thu Sep 17 11:11:51 2009 +0200
--- common/hush.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-)
common/hush.c +6 -1
@@ -3178,7 +3178,12 @@ int parse_stream_outer(struct in_str *inp, int flag)#ifndef __U_BOOT__run_list (ctx.list_head);#else - code =run_list (ctx.list_head); +if (ctx.list_head->num_progs) { + code =run_list (ctx.list_head); + }else { +free_pipe_list (ctx.list_head,0 ); +continue ; + }if (code ==-2 ) {/* exit */ b_free (&temp); code =0 ;
Signature · 1 line
1.7.4
PATCH 2/2 hush: Fix return code when using 'exit' in control structures
This fixes cases like this one, there hush used to return 0 :
=> if foo ; then do something ; exit 1 ; fi ; echo RC=$? Unknown command 'foo' - try 'help'
RC=1
Adapted from Barebox commit 2477fb1
From: Sascha Hauer <[email protected]>
Date: Tue, 23 Mar 2010 15:33:43 +0100
--- common/hush.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
common/hush.c +2 -2
@@ -1938,7 +1938,7 @@ static int run_list_real(struct pipe *pi)#else if (rcode <-1 ) { last_return_code = -rcode -2 ; -return -2 ;/* exit */ +return rcode;/* exit */ } last_return_code=(rcode ==0 ) ?0 :1 ;#endif
@@ -3184,7 +3184,7 @@ int parse_stream_outer(struct in_str *inp, int flag)free_pipe_list (ctx.list_head,0 );continue ; } -if (code ==-2 ) {/* exit */ +if (code <-1 ) {/* exit */ b_free (&temp); code =0 ;/* XXX hackish way to not allow exit from main loop */
Signature · 1 line
1.7.4
PATCH 2/2 hush: Fix return code when using 'exit' in control structures
In reply to Wolfgang DenkQuoted 6 lines · In message <[email protected]> you wrote:
This fixes cases like this one, there hush used to return 0 :
=> if foo ; then do something ; exit 1 ; fi ; echo RC=$? Unknown command 'foo' - try 'help'
RC=1
Quoted 8 lines
Adapted from Barebox commit 2477fb1
From: Sascha Hauer <[email protected]>
Date: Tue, 23 Mar 2010 15:33:43 +0100Signed-off-by Wolfgang Denk <[email protected]>--- common/hush.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
I will drop these hush patches.
Further testing shows that they don't really fix the problems.
Looking closer at the current hush code I think it's a waste of time to try fixing these things; we should rather throw it away and re-import a recent version from BusyBox, which would also bring a few nice features like shell functions and the like.
Best regards,
Wolfgang Denk
Signature · 4 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Computers are not intelligent. They only think they are.