Charles Levert wrote: > * On Friday 2005-11-11 at 22:09:17 +0100, Benno Schulenberg wrote: > > Ideally, what should grep do when options conflict? > > > > 1) Abort with an error message. > > 2) Give a warning and let an arbitrary option take precedence, > > depending on how things are implemented. > > 3) Say nothing and always have the last of the conflicting > > options determine the outcome.
[Skipping the details for now.] > 8. ... > The use of conflicting > mutually-exclusive arguments produces > undefined results, Okay, so this allows for the current situation, solution 2). > 11. The order of different options > relative to one another should > not matter, This disallows solution 3), which I preferred, but which would be complicated anyway. Well, then I would prefer solution 1), always abort if two options cannot both be satisfied: better have no output at all instead of output that is different from what one thought, not notice it (grep being used in a pipe), and interpret the result wrong. > unless the options are > documented as mutually-exclusive > and such an option is documented to > override any incompatible options > preceding it. This will need to be documented then at least for the -d and -r combinations. > If an option that > has option-arguments is repeated, > the option and option-argument > combinations should be interpreted > in the order specified on the > command line. This I understand to mean that "-C2 -C5" means "-C5", and "-C5 -C2" means "-C2", because if max() was used here, then the order wouldn't matter. GNU grep behaves this way (last one counts), but GNU diff simply aborts: "diff: conflicting output style options". Benno
