Skip to content
Snippets Groups Projects
Commit cc57eeb2 authored by g0dil's avatar g0dil
Browse files

Scheduler/Console: Fix option parsing bug (closes: #14841)

Scheduler/Console: Add additional information to exceptions thrown while parsing command line arguments
parent 3c79c686
No related branches found
No related tags found
No related merge requests found
......@@ -271,7 +271,6 @@ BOOST_AUTO_UNIT_TEST(executorAuto)
BOOST_CHECK_EQUAL( os.str(), "testCommand\n" );
}
commands.clear();
senf::console::root().remove("tdir1");
senf::console::root().remove("dir2");
......
......@@ -60,7 +60,13 @@ prefix_ void senf::console::detail::ProgramOptionsSource::v_parse(RestrictedExec
break;
}
else if (boost::algorithm::starts_with(arg, std::string("--")) && arg.size() > 2)
parseLongOption(arg.substr(2), executor);
try {
parseLongOption(arg.substr(2), executor);
}
catch (senf::ExceptionMixin & e) {
e << "\nwhile parsing command line option: " << arg;
throw;
}
else if (boost::algorithm::starts_with(arg, std::string("-")) && arg.size() > 1) {
for (std::string::size_type i (1); i<arg.size(); ++i) {
char opt (arg[i]);
......@@ -87,7 +93,13 @@ prefix_ void senf::console::detail::ProgramOptionsSource::v_parse(RestrictedExec
}
if (boost::algorithm::starts_with(longOpt, std::string("--")))
longOpt = longOpt.substr(2);
parseLongOption(longOpt, executor);
try {
parseLongOption(longOpt, executor);
}
catch (senf::ExceptionMixin & e) {
e << "\nwhile parsing command line option: -" << opt << ' ' << param;
throw;
}
}
}
else
......@@ -107,7 +119,7 @@ senf::console::detail::ProgramOptionsSource::parseLongOption(std::string const &
ParseCommandInfo cmd;
Path path;
DirectoryNode::ptr cwd (executor.root().thisptr());
std::string::size_type b (0);
while (b < name.size()) {
......@@ -118,8 +130,10 @@ senf::console::detail::ProgramOptionsSource::parseLongOption(std::string const &
DirectoryNode::ChildrenRange completions (cwd->completions(key));
if (has_one_elt(completions))
key = completions.begin()->first;
else
else {
e -= 1;
continue;
}
}
path.push_back(WordToken(key));
if (e < name.size())
......@@ -135,7 +149,7 @@ senf::console::detail::ProgramOptionsSource::parseLongOption(std::string const &
b = name.size();
}
}
cmd.command(path);
parser_.parseArguments(value, cmd);
executor(std::cerr, cmd);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment