From c8a49971cbec622573980c276c860aa43ba43b36 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Fri, 6 Sep 2013 12:18:46 -0500 Subject: Make [-abc] exclude logic clear argument slots when disabling options. --- lib/args.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/args.c b/lib/args.c index 73063d66..f6bc4827 100644 --- a/lib/args.c +++ b/lib/args.c @@ -124,7 +124,14 @@ static int gotflag(struct getoptflagstate *gof, struct opts *opt) } // Set flags - toys.optflags &= ~opt->dex[0]; + if (toys.optflags & opt->dex[0]) { + struct opts *clr; + unsigned i = 1; + + for (clr=gof->opts, i=1; ; clr = clr->next, i<<=1) + if (clr->arg && (i & toys.optflags)) clr->arg = 0; + toys.optflags &= ~opt->dex[0]; + } toys.optflags |= opt->dex[1]; gof->excludes |= opt->dex[2]; if (opt->flags&2) gof->stopearly=2; -- cgit v1.2.3