changeset 1437:1d79c0c23f69 draft

Fix bug reported by Ashwini Sharma: [-abc] syntax to switch off a command forget s _all_ saved command line arguments in GLOBALS(), not just for the command bein g dropped.
author Rob Landley <rob@landley.net>
date Fri, 15 Aug 2014 18:53:01 -0500
parents d7be3d62a5cb
children 7a3afbc7fc8b
files lib/args.c
diffstat 1 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/lib/args.c	Fri Aug 15 10:50:39 2014 -0500
+++ b/lib/args.c	Fri Aug 15 18:53:01 2014 -0500
@@ -138,15 +138,18 @@
     error_exit("Unknown option %s", gof->arg);
   }
 
-  // Set flags
+  // Might enabling this switch off something else?
   if (toys.optflags & opt->dex[0]) {
     struct opts *clr;
     unsigned i = 1;
 
+    // Forget saved argument for flag we switch back off
     for (clr=gof->opts, i=1; clr; clr = clr->next, i<<=1)
-      if (clr->arg && (i & toys.optflags)) *clr->arg = 0;
+      if (clr->arg && (i & toys.optflags & opt->dex[0])) *clr->arg = 0;
     toys.optflags &= ~opt->dex[0];
   }
+
+  // Set flags
   toys.optflags |= opt->dex[1];
   gof->excludes |= opt->dex[2];
   if (opt->flags&2) gof->stopearly=2;