3 ms·
That only holds when 'o' and 'f' are both boolean "flags" taking no arguments. If 'f' is more like --file=x then it takes an argument. More specifically, geto
by cb321 3y ago
That only holds when 'o' and 'f' are both boolean "flags" taking no arguments. If 'f' is more like --file=x then it takes an argument.
More specifically, getopt(3) in POSIX lets programmers very this by giving a format string. "o:f" would make your example parse as "-o" "foo" while "of:" would make it parse as "-o" "-f" "oo" and an "of" format would make it parse as you describe, "-o" "-f" "-o" "-o".
( darnir mentioned parts of this above: https://news.ycombinator.com/item?id=38968612 https://news.ycombinator.com/item?id=38968612 using the term "single character flags" to indicate no argument. )
Also, while --long-option is GNU, gcc which is perhaps the aboriginal GNU command-line utility uses single dash as in, e.g. `gcc -pipe`, though it also accepts `gcc --help`. CL syntax remains quite varied in the wild.