diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2020-06-03 14:38:39 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2020-06-03 16:47:34 +0300 |
commit | f50d0d58c8eb659e803282e19cf15398e3a8e373 (patch) | |
tree | ad9d6a434661cb08a89b8871601d4dc55235a8ae /libbuild2/functions-process.cxx | |
parent | 450c907b2a10c43748b8c15df20d92ff782269c7 (diff) |
Fix $process.run() to properly handle proces_path_ex
Diffstat (limited to 'libbuild2/functions-process.cxx')
-rw-r--r-- | libbuild2/functions-process.cxx | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/libbuild2/functions-process.cxx b/libbuild2/functions-process.cxx index e6c0582..de06f27 100644 --- a/libbuild2/functions-process.cxx +++ b/libbuild2/functions-process.cxx @@ -210,19 +210,39 @@ namespace build2 if (args.empty () || args[0].empty ()) fail << "executable name expected in process." << fn << "()"; - process_path pp; + optional<process_path> pp; + try { size_t erase; - // This can be a process_path (pair) or just a path. + // This can be a process_path (pair), process_path_ex (process_path + // followed by the name@ and checksum@ pairs), or just a path. + // + // First, check if the arguments begin with a process_path[_ex] and, if + // that's the case, only use the leading name/pair to create the process + // path, discarding the meta-information. // - if (args[0].pair) + if (args[0].file ()) { - pp = convert<process_path> (move (args[0]), move (args[1])); - erase = 2; + // Find the end of the process_path[_ex] value. + // + auto b (args.begin ()); + auto i (value_traits<process_path_ex>::find_end (args)); + + if (b->pair || i != b + 1) // First is a pair or pairs after. + { + pp = convert<process_path> ( + names (make_move_iterator (b), + make_move_iterator (b + (b->pair ? 2 : 1)))); + + erase = i - b; + } } - else + + // Fallback to a path, if this is not a process path. + // + if (!pp) { // Strip the builtin-escaping '^' character, if present. // @@ -254,7 +274,7 @@ namespace build2 fail << "invalid process." << fn << "() executable path: " << e; } - return pair<process_path, strings> (move (pp), + return pair<process_path, strings> (move (*pp), program_args (move (args), fn)); } |