aboutsummaryrefslogtreecommitdiff
path: root/debianutils/run_parts.c
diff options
context:
space:
mode:
authorPeter Korsgaard <jacmet@sunsite.dk>2013-02-28 09:59:23 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2013-02-28 09:59:23 +0100
commit0496e824a5b97edc9991f62c7c74f9b24b16edc7 (patch)
tree461a62c88e5b8268d8444bad9e87017eee2bb864 /debianutils/run_parts.c
parentf59d563399be3d9af3e7b4673e13905d28f2339b (diff)
downloadbusybox-w32-0496e824a5b97edc9991f62c7c74f9b24b16edc7.tar.gz
busybox-w32-0496e824a5b97edc9991f62c7c74f9b24b16edc7.tar.bz2
busybox-w32-0496e824a5b97edc9991f62c7c74f9b24b16edc7.zip
run-parts: add --exit-on-error | -e support
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 <jacmet@sunsite.dk> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'debianutils/run_parts.c')
-rw-r--r--debianutils/run_parts.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/debianutils/run_parts.c b/debianutils/run_parts.c
index 005b30420..6be83edf9 100644
--- a/debianutils/run_parts.c
+++ b/debianutils/run_parts.c
@@ -27,10 +27,11 @@
27 * -a ARG argument. Pass ARG as an argument the program executed. It can 27 * -a ARG argument. Pass ARG as an argument the program executed. It can
28 * be repeated to pass multiple arguments. 28 * be repeated to pass multiple arguments.
29 * -u MASK umask. Set the umask of the program executed to MASK. 29 * -u MASK umask. Set the umask of the program executed to MASK.
30 * -e exit as soon as a script returns with a non-zero exit code
30 */ 31 */
31 32
32//usage:#define run_parts_trivial_usage 33//usage:#define run_parts_trivial_usage
33//usage: "[-t"IF_FEATURE_RUN_PARTS_FANCY("l")"] [-a ARG]... [-u MASK] DIRECTORY" 34//usage: "[-t"IF_FEATURE_RUN_PARTS_FANCY("l")"] [-a ARG]... [-u MASK] [-e] DIRECTORY"
34//usage:#define run_parts_full_usage "\n\n" 35//usage:#define run_parts_full_usage "\n\n"
35//usage: "Run a bunch of scripts in DIRECTORY\n" 36//usage: "Run a bunch of scripts in DIRECTORY\n"
36//usage: "\n -t Dry run" 37//usage: "\n -t Dry run"
@@ -39,6 +40,7 @@
39//usage: ) 40//usage: )
40//usage: "\n -a ARG Pass ARG as argument to programs" 41//usage: "\n -a ARG Pass ARG as argument to programs"
41//usage: "\n -u MASK Set umask to MASK before running programs" 42//usage: "\n -u MASK Set umask to MASK before running programs"
43//usage: "\n -e Exit as soon as a script returns with a non-zero exit code"
42//usage: 44//usage:
43//usage:#define run_parts_example_usage 45//usage:#define run_parts_example_usage
44//usage: "$ run-parts -a start /etc/init.d\n" 46//usage: "$ run-parts -a start /etc/init.d\n"
@@ -74,7 +76,8 @@ enum {
74 OPT_a = (1 << 1), 76 OPT_a = (1 << 1),
75 OPT_u = (1 << 2), 77 OPT_u = (1 << 2),
76 OPT_t = (1 << 3), 78 OPT_t = (1 << 3),
77 OPT_l = (1 << 4) * ENABLE_FEATURE_RUN_PARTS_FANCY, 79 OPT_e = (1 << 4),
80 OPT_l = (1 << 5) * ENABLE_FEATURE_RUN_PARTS_FANCY,
78}; 81};
79 82
80#if ENABLE_FEATURE_RUN_PARTS_FANCY 83#if ENABLE_FEATURE_RUN_PARTS_FANCY
@@ -127,6 +130,7 @@ static const char runparts_longopts[] ALIGN1 =
127 "arg\0" Required_argument "a" 130 "arg\0" Required_argument "a"
128 "umask\0" Required_argument "u" 131 "umask\0" Required_argument "u"
129 "test\0" No_argument "t" 132 "test\0" No_argument "t"
133 "exit-on-error\0" No_argument "e"
130#if ENABLE_FEATURE_RUN_PARTS_FANCY 134#if ENABLE_FEATURE_RUN_PARTS_FANCY
131 "list\0" No_argument "l" 135 "list\0" No_argument "l"
132 "reverse\0" No_argument "r" 136 "reverse\0" No_argument "r"
@@ -150,7 +154,7 @@ int run_parts_main(int argc UNUSED_PARAM, char **argv)
150#endif 154#endif
151 /* We require exactly one argument: the directory name */ 155 /* We require exactly one argument: the directory name */
152 opt_complementary = "=1:a::"; 156 opt_complementary = "=1:a::";
153 getopt32(argv, "ra:u:t"IF_FEATURE_RUN_PARTS_FANCY("l"), &arg_list, &umask_p); 157 getopt32(argv, "ra:u:te"IF_FEATURE_RUN_PARTS_FANCY("l"), &arg_list, &umask_p);
154 158
155 umask(xstrtou_range(umask_p, 8, 0, 07777)); 159 umask(xstrtou_range(umask_p, 8, 0, 07777));
156 160
@@ -193,6 +197,9 @@ int run_parts_main(int argc UNUSED_PARAM, char **argv)
193 bb_perror_msg("can't execute '%s'", name); 197 bb_perror_msg("can't execute '%s'", name);
194 else /* ret > 0 */ 198 else /* ret > 0 */
195 bb_error_msg("%s exited with code %d", name, ret & 0xff); 199 bb_error_msg("%s exited with code %d", name, ret & 0xff);
200
201 if (option_mask32 & OPT_e)
202 xfunc_die();
196 } 203 }
197 204
198 return n; 205 return n;