[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Abort on invalid options.

From: Benno Schulenberg
Subject: Re: [PATCH] Abort on invalid options.
Date: Thu, 05 Apr 2007 23:20:03 +0200
User-agent: KMail/1.9.6

Otavio Salvador wrote:
> address@hidden writes:
> > From: Benno Schulenberg <address@hidden>
> >
> >  _parse_options (int* argc_ptr, char*** argv_ptr)
> >  {
> > [snip]
> >  }
> >
> > +if (wrong == 1)
> > +        return 0;
> > +
> >  *argc_ptr -= optind;
> >  *argv_ptr += optind;
> >  return 1;
> I think the if (wrong == 1) block needs to be after the pointers
> change.

You will have to explain why, since when _parse_options() returns 
with 0, _init() immediately jumps to error_done_commands and the 
arg pointers aren't used any more, as far as I can tell.  But it 
won't do any harm to put the return after those pointer changes.
So, okay.

> Another way of doing it might be changing the last return to:
> #v+
>         return !wrong;
> #v-
> What do you think?

That is indeed more elegant.  New patch is coming up.

But that is not enough to make option parsing satisfactory:
  parted -lm
  parted -ml
do not behave the same way.  And GNU policy says that the order of 
options shouldn't matter.

will happily execute the -l option, whereas for example grep will 
not do anything wen it finds just a single option that it doesn't 
understand.  And parted is dangerous -- it should be at least as 
reluctant to do anything when the input is not entirely correct.

So the option handling needs some more work.  But not today.  :)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]