Re: [PATCH] run-parts: add --exit-on-error | -e support

2013-02-28 Thread Denys Vlasenko
On Wed, Feb 27, 2013 at 2:14 PM, Peter Korsgaard jac...@sunsite.dk wrote:
 The big run-parts supports a handy --exit-on-error to stop execution on
 errors, so lets support it as well.

 Upstream doesn't have a short option for it, but I've used '-e' for busybox.

 Signed-off-by: Peter Korsgaard jac...@sunsite.dk

Applied, thanks!
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: [PATCH] run-parts: add --exit-on-error | -e support

2013-02-28 Thread Peter Korsgaard
 Denys == Denys Vlasenko vda.li...@googlemail.com writes:

 Denys On Wed, Feb 27, 2013 at 2:14 PM, Peter Korsgaard jac...@sunsite.dk 
wrote:
  The big run-parts supports a handy --exit-on-error to stop execution on
  errors, so lets support it as well.
  
  Upstream doesn't have a short option for it, but I've used '-e' for busybox.
  
  Signed-off-by: Peter Korsgaard jac...@sunsite.dk

 Denys Applied, thanks!

Thanks. Your followup patch to drop the short options did something
funky to the dashes though. I'll send a patch to fix.

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


[PATCH] run-parts: add --exit-on-error | -e support

2013-02-27 Thread Peter Korsgaard
The big run-parts supports a handy --exit-on-error to stop execution on
errors, so lets support it as well.

Upstream doesn't have a short option for it, but I've used '-e' for busybox.

Signed-off-by: Peter Korsgaard jac...@sunsite.dk
---
 debianutils/run_parts.c |   13 ++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/debianutils/run_parts.c b/debianutils/run_parts.c
index 005b304..6be83ed 100644
--- a/debianutils/run_parts.c
+++ b/debianutils/run_parts.c
@@ -27,10 +27,11 @@
  * -a ARG   argument. Pass ARG as an argument the program executed. It can
  *  be repeated to pass multiple arguments.
  * -u MASK  umask. Set the umask of the program executed to MASK.
+ * -e   exit as soon as a script returns with a non-zero exit code
  */
 
 //usage:#define run_parts_trivial_usage
-//usage:   [-tIF_FEATURE_RUN_PARTS_FANCY(l)] [-a ARG]... [-u MASK] 
DIRECTORY
+//usage:   [-tIF_FEATURE_RUN_PARTS_FANCY(l)] [-a ARG]... [-u MASK] 
[-e] DIRECTORY
 //usage:#define run_parts_full_usage \n\n
 //usage:   Run a bunch of scripts in DIRECTORY\n
 //usage: \n   -t  Dry run
@@ -39,6 +40,7 @@
 //usage:   )
 //usage: \n   -a ARG  Pass ARG as argument to programs
 //usage: \n   -u MASK Set umask to MASK before running programs
+//usage: \n   -e  Exit as soon as a script returns with a 
non-zero exit code
 //usage:
 //usage:#define run_parts_example_usage
 //usage:   $ run-parts -a start /etc/init.d\n
@@ -74,7 +76,8 @@ enum {
OPT_a = (1  1),
OPT_u = (1  2),
OPT_t = (1  3),
-   OPT_l = (1  4) * ENABLE_FEATURE_RUN_PARTS_FANCY,
+   OPT_e = (1  4),
+   OPT_l = (1  5) * ENABLE_FEATURE_RUN_PARTS_FANCY,
 };
 
 #if ENABLE_FEATURE_RUN_PARTS_FANCY
@@ -127,6 +130,7 @@ static const char runparts_longopts[] ALIGN1 =
arg\0 Required_argument a
umask\0   Required_argument u
test\0No_argument   t
+   exit-on-error\0 No_argument e
 #if ENABLE_FEATURE_RUN_PARTS_FANCY
list\0No_argument   l
reverse\0 No_argument   r
@@ -150,7 +154,7 @@ int run_parts_main(int argc UNUSED_PARAM, char **argv)
 #endif
/* We require exactly one argument: the directory name */
opt_complementary = =1:a::;
-   getopt32(argv, ra:u:tIF_FEATURE_RUN_PARTS_FANCY(l), arg_list, 
umask_p);
+   getopt32(argv, ra:u:teIF_FEATURE_RUN_PARTS_FANCY(l), arg_list, 
umask_p);
 
umask(xstrtou_range(umask_p, 8, 0, 0));
 
@@ -193,6 +197,9 @@ int run_parts_main(int argc UNUSED_PARAM, char **argv)
bb_perror_msg(can't execute '%s', name);
else /* ret  0 */
bb_error_msg(%s exited with code %d, name, ret  
0xff);
+
+   if (option_mask32  OPT_e)
+   xfunc_die();
}
 
return n;
-- 
1.7.10.4

___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox