Opened 7 years ago

#11393 new Bugs

boost::program_options accepting switch-options that match the beginning of defined option, but is not full option typed out.

Reported by: eg@… Owned by: Vladimir Prus
Milestone: To Be Determined Component: program_options
Version: Boost 1.58.0 Severity: Problem
Keywords: Cc:

Description

With:

namespace po = boost::program_options; po::options_description desc ("options"); desc.add_options ()

( "help,h", "print this help message") ( "config,c", po::value<ustring>(), "config file, default: $XDG_CONFIG_HOME/astroid/config") ( "new-config,n", "make new default config, then exit") ( "mailto,m", po::value<ustring>(), "compose mail with mailto url or address") ( "no-auto-poll", "do not poll automatically");

po::variables_map vm;

bool show_help = false;

try {

po::store ( po::parse_command_line (argc, argv, desc), vm );

} catch (po::unknown_option &ex) {

cout << "unknown option" << endl; cout << ex.what() << endl; show_help = true;

}

running:

./program --asdf

fails, but running:

./program --hel

is parsed as --help.

Change History (0)

Note: See TracTickets for help on using tickets.