From: Ersek, Laszlo on
On Thu, 6 May 2010, Tetsuya wrote:

> Hello, I have to implement a little utility that can get some commandline
> options, and I decided to use getopt_long_only().

getopt_long_only() seems to have a *feature* that you can abbreviate
options as long as they remain unambiguous. The point of long options is
convenience (well, and offering more options than getopt() can with the
Portable Character Set).

[snip]


> It seems that getopt_long_only() looks only the first non ambiguous
> character of the option, and I want it to look for EXACTLY --name, and
> not --nam o anything else (the same goes for the other options).

Why?

Anyway, since each option takes a mandatory argument, it shouldn't be that
hard to check if the command line carries an even number of arguments, and
then to process the arguments in pairs. Check the first component of each
pair with strcmp() against each supported option. Or set up a sorted array
and use bsearch(), for ultimate overkill.

.... getopt_clip() might be what you want; I don't know if it's available
on GNU/Linux.

Cheers,
lacos