On Wed, Mar 9, 2016 at 9:35 PM, Michael McConville <[email protected]> wrote:
> Jeremie Courreges-Anglas wrote:
>> >> @@ -66,13 +66,18 @@ main(int argc, char *argv[])
>> >>            argv++;
>> >>    }
>> >>
>> >> -  while ((ch = getopt(argc, argv, "n:")) != -1) {
>> >> +  while ((ch = getopt(argc, argv, "c:n:")) != -1) {
>> >>            switch (ch) {
>> >> +          case 'c':
>> >> +                  dobytes = 1;
>> >> +                  p = optarg;
>> >> +                  break;
>> >>            case 'n':
>> >> +                  dobytes = 0;
>> >
>> > It's already initialized to 0, which is necessary for the head -count
>> > style syntax.
>>
>> I followed the behavior of GNU head here: the last specified option
>> wins.  IIRC FreeBSD head(1) makes -c and -n incompatible.
>
> I feel like erroring on multiple options would be an improvement. I
> guess I can propose that as a separate diff when you're done.
>

I don't think erroring would be expected behaviour.

I think jca@ has the right approach (especially if it matches what
FreeBSD and others do in this case). Some posix tools say what they do
in this case with text like this:
"...the last option specified in each set shall determine the output."

The equivalent in our man pages is text like:

"It is not an error to specify more than one of the following mutually
exclusive options..."

"Where more than one option is specified from the same mutually
exclusive group, the last option given overrides the others"

(e.g. man df, man ls, etc).

Reply via email to