[PATCH] hush.c - simple support to return from functions

Denys Vlasenko vda.linux at googlemail.com
Fri Apr 17 23:46:34 UTC 2009


On Friday 17 April 2009 19:27, Bayram Kurumahmut wrote:
> 
> add builtin return function
> if flag_return_function is true, break current run_list() execution

The patch is in quoted-printable encoding, my oldish KMail
saved it with =3D instead of =, =20 instead of spaces etc.
I fixed it by hand.
Next time please send as attachment.

Build problem:

# make
  CC      shell/hush.o
cc1: warnings being treated as errors
shell/hush.c: In function 'builtin_return':
shell/hush.c:6877: error: unused parameter 'argv'
make[1]: *** [shell/hush.o] Error 1
make: *** [shell] Error 2

There are many examples in hush.c how to fix this:

static int builtin_return(char **argv UNUSED_PARAM)


-//     BLTIN("return"  , builtin_return  , "Return from a function"),
+       BLTIN("return"  , builtin_return  , "Return from a function"),

You forgot to frame it in #if ENABLE_HUSH_FUNCTIONS


Bug:

hush:
/.1/usr/srcdevel/bbox/fix/busybox.t2 # f() { false; return; }; { f; echo Hi; };
     (nothing is printed here)
/.1/usr/srcdevel/bbox/fix/busybox.t2 #

bash:
# f() { false; return; }; { f; echo Hi; };
Hi
#


Bug #2:

hush:
/.1/usr/srcdevel/bbox/fix/busybox.t2 # f() { false; return; }; f; echo $?
0

bash:
# f() { false; return; }; f; echo $?
1


Bug #3:

hush:
/.1/usr/srcdevel/bbox/fix/busybox.t2 # return; echo Hi
Hi

bash:
# return; echo Hi
bash: return: can only `return' from a function or sourced script
Hi


I fixed these and applied the patch to svn.
Please do more thorough testing next time.

Thanks!
--
vda


More information about the busybox mailing list