Hi Theo, Theo de Raadt wrote on Mon, Aug 16, 2021 at 08:15:03AM -0600: > Jason McIntyre <j...@kerhand.co.uk> wrote:
>> well, in those cases i think the authors shared the viewpoint that >> mutually exclusive means you can;t mix them but in this case it is >> essentially not an error to do so, and so documented it that way. >> >> maybe it is more helpful to think of "mutually exclusive" as "causes >> an error", but i am not sure. Probably you are right that my description of "mutually exclusive" as "it errors out" was too narrow and that in some situations, understanding it in a broader sense of "the effect of combining them is unspecified" or even broader, "combining them provides no useful functionality" may be adequate. Still, "mutually exclusive" is not the same concept as "one overrides the other". > I agree with you that programs should not neccessary error out. > > I appreciate that you pointed at ls(1) before, which has so many options > I think we should look there for examples. > > -A List all entries except for `.' and `..'. Always set for the > superuser. > > -a Include directory entries whose names begin with a dot (`.'). > > These two options are not described as mutually exclusive, except, a > mutually exclusive action is described. > > How do -Aa and -aA behave? Try it. Just like -a alone. That is obviously reasonable because both options enlarge the set of names listed, and the set provided by -a is a strict superset of the set provided by -A. > Does POSIX take a position? Not as far as i see. POSIX does explicitly document them as mutually exclusive by having [-a | -A] in the SYNOPSIS, but what happens when both are provided appears to remain unspecified. > If POSIX doesn't take a position, why should we? We probably shouldn't. Since behaviour of -aA is unspecied, our behviour is not only reasonable but also conforming. Strictly speaking, it is undocumented, but easy to guess and certainly not surprising. > Should we break scripts that accidentally use both options? Absolutely not. Even if our page explicitly said "-a and -A are mutually exclusive", that should only be regarded as an indication that the combination *might* error out, not that it actually does - i failed to make that clear in my previous mail. > Argument composition does happen in scripting and interactive use. > > Should we search for places to make POSIX programs exit(1) if people > use them in the newly-defined incorrect way? No. But conversely, we shouldn't attempt to hunt down all cases either where programs currently error out when given mutually exlusive options and make them all override each other. In many cases, it is better to not jump to conclusions when the user didn't make it clear what they wanted. Unsurprisingly, sane behaviour depends on the individual program and options. > If we decide to not cause ls(1) -a and -A to exit, then I think we > should not make other programs exit either. Sounds reasonable. > And then probably follow jmc's lead that "mutually exclusive" either > in text, or in interpreted text, doesn't neccessarily describe an exit > action. That's certainly the current situation. In some pages, it is used for combinations that error out, in some for options that override each other, and when left unqualified, it can mean "the effect of combining is not considered valid syntax and may have an unspecified effect". The latter is often fine (like for ls -aA) and more rarely weird (like for jot -b foo -w bar 3 97). When it is weird, improving it may be worthwhile. Yours, Ingo