From f50d0d58c8eb659e803282e19cf15398e3a8e373 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Wed, 3 Jun 2020 14:38:39 +0300 Subject: Fix $process.run() to properly handle proces_path_ex --- libbuild2/functions-process.cxx | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) (limited to 'libbuild2/functions-process.cxx') 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 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 (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::find_end (args)); + + if (b->pair || i != b + 1) // First is a pair or pairs after. + { + pp = convert ( + 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 (move (pp), + return pair (move (*pp), program_args (move (args), fn)); } -- cgit v1.1