Re: Optional option argument
Anthony Carrico 09 Jul 2020 00:18 UTC
On 7/8/20 8:07 PM, John Cowan wrote:
> yes, I meant the second option; I myself would favor the first, but
> that's not what GNU says.
What? I think we are missing each other.
The GNU spec says "if there is text in the current argv-element then it
is returned in optarg, otherwise optarg is set to zero". That is the
first option.
1. argv-element is "-obar"
2. o is recognized as an option taking an optional arg.
3. the text "bar" is still in the current argv-element
4. so "bar" is returned in optarg.
This was your first option.
This also means that "-o bar" gets no argument (which is strange).
--
Anthony Carrico