From 9e429189d753cf3a4e194af8bcb5f2c2d272d7c2 Mon Sep 17 00:00:00 2001 From: q66 Date: Tue, 9 May 2017 23:58:20 +0200 Subject: [PATCH] more foolproof subprocess interface --- ostd/process.hh | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/ostd/process.hh b/ostd/process.hh index 27e69ab..e809a93 100644 --- a/ostd/process.hh +++ b/ostd/process.hh @@ -310,15 +310,18 @@ private: "The arguments must be strings" ); std::vector 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); }