On Thu, Apr 30, 2009 at 3:56 PM, James Carlson <james.d.carlson at sun.com> wrote: > Don Cragun writes: >> The reason I asked to discuss ls during yesterday's meeting is that the >> materials provided in the initial mail (before the man page was added to >> the case directory) contained the following: >> ? ? ? --color[=WHEN], --colour[=WHEN] >> which shows WHEN as an optional option-argument to the --color and >> --colour long options and indicates that the '=' is not required. > > Actually, it shows that the '=' form *is* required. > > The dangerous form that I was concerned about is: > > ? ? ? ?--color [WHEN] > > ... that is, an optional argument that consumes an additional argv[] > entry, but does so only conditionally. > > If that's actually allowable, then I do think a warning about the > syntax is appropriate. > >> list the file 'auto' never using color. ?The commands: >> ? ? ? ls -l --color=auto >> and >> ? ? ? ls -l --color= auto >> are not ambiguous, but these are not the only allowed forms. > > That part isn't clear to me. ?The materials say that only > '--color[=WHEN]' is allowed, and not the other forms you're > describing. > > It's possible that the submitter is confused about what he's actually > asking for, or that we're confused about the way it'll be documented > and will function. > > I'd like to hear from the submitter.
For optional arguments, --option=ARG is the only form accepted For mandatory arguments, --option=ARG or --option ARG After lots of reading, rereading, parsing, and reparsing, I believe using getopt_long(3c) to process the arguments, with '+' being the first character of the option string, gives the desired behavior (without breaking any standards). Thus ls --color=auto, ls --color=never or ls --color. 'ls --color auto' means the same as 'ls --color=auto -- auto' (i.e. auto detect color, list something named 'auto'). >> It also listed: >> ? ? ? --time-style=[STYLE] >> which shows that the '=' is required for this long option, and >> presumably means that if STYLE is the empty string it is equivalent to >> --time-style=locale. > > True. ?That's actually a required option argument, and just one that > happens to be allow an empty string. ?It's not an optional option > argument. That should be --time-style=STYLE, the style is mandatory, thus --time-style=STYLE, or --time-style STYLE are both acceptable. >> The man page also does not list any of the new long options in the >> SYNOPSIS section and didn't make any adjustments to the ATTRIBUTES >> section in the places where it indicates that -A, -b, -e, -E, -h, -S, >> -v, -V, -@, -/, and -% are not covered by the standards (thereby >> indicating that these new long option are required by the POSIX and >> SUS specs. ?I assume all of these issues will be fixed before the >> man page is published, but I would like the project team to acknowledge >> that this needs to be fixed. > > OK. ?Actually, I think these are issues for the man page writers. > > The man page contents are interesting and helpful for ARC review, and > certainly getting it right is important, but I do not agree that > detailed man page reviews are architecture. I'm happy to submit a corrected manpage edit with the stuff I'm working on, since I've been pretty much navigating this on my own, just let me know what's needed. I can attempt it for preexisting flags as well, but would feel less comfortable about those, not being involved in their creation.