aboutsummaryrefslogtreecommitdiff
path: root/lib/args.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2019-03-10 23:05:24 -0500
committerRob Landley <rob@landley.net>2019-03-10 23:05:24 -0500
commit677cd8cea214ef73bbbed965580575c9abaa048e (patch)
tree09f113fdd434384c58c15eebd663b1b1be01d805 /lib/args.c
parent502b10c2ab6bb273bf280ba355fa30869b955d56 (diff)
downloadtoybox-677cd8cea214ef73bbbed965580575c9abaa048e.tar.gz
Add TOYFLAG_ARGFAIL() to allow argument parsing failures to exit with value.
Diffstat (limited to 'lib/args.c')
-rw-r--r--lib/args.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/args.c b/lib/args.c
index 54106c25..1ebc4f2d 100644
--- a/lib/args.c
+++ b/lib/args.c
@@ -388,6 +388,8 @@ void get_optflags(void)
// Option parsing is a two stage process: parse the option string into
// a struct opts list, then use that list to process argv[];
+ toys.exitval = toys.which->flags >> 24;
+
// Allocate memory for optargs
saveflags = 0;
while (toys.argv[saveflags++]);
@@ -495,6 +497,8 @@ notflag:
help_exit("Needs %s-%s", s[1] ? "one of " : "", needs);
}
+ toys.exitval = 0;
+
if (CFG_TOYBOX_FREE) {
llist_traverse(gof.opts, free);
llist_traverse(gof.longopts, free);