aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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;