more foolproof subprocess interface

master
Daniel Kolesa 2017-05-09 23:58:20 +02:00
parent 2bab256b4d
commit 9e429189d7
1 changed files with 9 additions and 6 deletions

View File

@ -310,15 +310,18 @@ private:
"The arguments must be strings"
);
std::vector<std::string> argv;
if (cmd.empty()) {
if (args.empty()) {
throw process_error{"no arguments given"};
}
cmd = args[0];
}
for (; !args.empty(); args.pop_front()) {
argv.emplace_back(args.front());
}
if (argv.empty()) {
throw process_error{"no arguments given"};
}
if (cmd.empty()) {
cmd = argv[0];
if (cmd.empty()) {
throw process_error{"no command given"};
}
}
open_impl(std::string{cmd}, argv, use_path);
}