diff mbox series

[11/13] apply: return -1 from option callback instead of calling exit(1)

Message ID 20181105064358.GK25864@sigill.intra.peff.net (mailing list archive)
State New, archived
Headers show
Series parseopt fixes from -Wunused-parameters | expand

Commit Message

Jeff King Nov. 5, 2018, 6:43 a.m. UTC
The option callback for "apply --whitespace" exits with status "1" on
error. It makes more sense for it to just return an error to
parse-options. That code will exit, too, but it will use status "129"
that is customary for option errors.

The exit() dates back to aaf6c447aa (builtin/apply: make
parse_whitespace_option() return -1 instead of die()ing, 2016-08-08).
That commit gives no reason why we'd prefer the current exit status (it
looks like it was just bumping the "die" up a level in the callstack,
but did not go as far as it could have).

Signed-off-by: Jeff King <peff@peff.net>
---
 apply.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/apply.c b/apply.c
index d1ca6addeb..c4c9f849b1 100644
--- a/apply.c
+++ b/apply.c
@@ -4812,7 +4812,7 @@  static int apply_option_parse_whitespace(const struct option *opt,
 	struct apply_state *state = opt->value;
 	state->whitespace_option = arg;
 	if (parse_whitespace_option(state, arg))
-		exit(1);
+		return -1;
 	return 0;
 }