Boost C++ Libraries: Ticket #860: program_options: long options use prefix only https://svn.boost.org/trac10/ticket/860 <pre class="wiki">Using program_options defaults, while scanning for long_options, only the prefix is used. So long options which begin with the same alphabets result in ambiguous results. A program which takes --foo(-f), --fool(-l), --fooled(-d) as options currently works like the following: ~/program_options_tests$ ./a.out -f foo option selected ~/program_options_tests$ ./a.out -l fool option selected ~/program_options_tests$ ./a.out -d fooled option selected ~/program_options_tests$ ./a.out --fo error: ambiguous option fo ~/program_options_tests$ ./a.out --foo error: ambiguous option foo ~/program_options_tests$ ./a.out --fool error: ambiguous option fool ~/program_options_tests$ ./a.out --foole fooled option selected ~/program_options_tests$ ./a.out --fooled fooled option selected Expected results: ---------------- ./a.out --foo ./a.out --fool ./a.out --fooled should have been valid options ./a.out --foole should have been an invalid option Actual Results: -------------- ./a.out --foo ./a.out --fool failed. ./a.out --foole was accepted as --fooled option. The program used is attached. </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/860 Trac 1.4.3 Vladimir Prus Wed, 21 Mar 2007 16:44:02 GMT status changed https://svn.boost.org/trac10/ticket/860#comment:1 https://svn.boost.org/trac10/ticket/860#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> </ul> <pre class="wiki">Logged In: YES user_id=321498 Originator: NO Thanks for the report! You can disable this behaviour by passing the 'style' parameter to the parse_command_line function explicitly, and using 'default_style ^ allow_guessing' for the style. This will disable guessing of long options based on prefix completely. If that still does not solve you problem, feel free to reopen this issue. </pre> Ticket mgruenke Mon, 26 Mar 2007 19:08:24 GMT <link>https://svn.boost.org/trac10/ticket/860#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/860#comment:2</guid> <description> <pre class="wiki">Logged In: YES user_id=343027 Originator: NO Shouldn't it provide compatible behavior with getopt_long(), by default? I consider it a bug that (by default) it accepts longopts I didn't specify, regardless of whether there's any shadowing of other options. </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>Vladimir Prus</dc:creator> <pubDate>Mon, 09 Apr 2007 08:19:10 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/860#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/860#comment:3</guid> <description> <pre class="wiki">Logged In: YES user_id=321498 Originator: NO I don't think getopt_long is something we're required to emulate. It looks that whether this is bug or not is not clear, so I'm gonna close this bug report, at least until more users come and complain. </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Mon, 24 Sep 2007 00:59:33 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/860#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/860#comment:4</guid> <description> <p> I'll complain too ;-) I think the default settings should work as the original poster expected. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>jotik</dc:creator> <pubDate>Wed, 01 Aug 2012 07:22:08 GMT</pubDate> <title>severity set https://svn.boost.org/trac10/ticket/860#comment:5 https://svn.boost.org/trac10/ticket/860#comment:5 <ul> <li><strong>severity</strong> → <span class="trac-field-new">Problem</span> </li> </ul> <p> Me too. </p> Ticket