From af498a19d6c9c42748521225b7daae671a5f58b5 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 1 Nov 2019 11:39:31 +0300 Subject: Fix assertion failure in pkg-build for --verbose 4 --- bpkg/pkg-build.cxx | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/bpkg/pkg-build.cxx b/bpkg/pkg-build.cxx index fa788e2..7a2168c 100644 --- a/bpkg/pkg-build.cxx +++ b/bpkg/pkg-build.cxx @@ -2826,15 +2826,26 @@ namespace bpkg auto arg_string = [&arg_parsed, &arg_sys] (const pkg_arg& a, bool options = true) -> string { - assert (arg_parsed (a)); - string r (options && a.options.dependency () ? "?" : string ()); - r += package_string (a.name, - (a.constraint && !wildcard (*a.constraint) - ? a.constraint - : nullopt), - arg_sys (a)); + // Quote an argument if empty or contains spaces. + // + auto append = [&r] (const string& a) + { + if (a.empty () || a.find (' ') != string::npos) + r += '"' + a + '"'; + else + r += a; + }; + + if (arg_parsed (a)) + r += package_string (a.name, + (a.constraint && !wildcard (*a.constraint) + ? a.constraint + : nullopt), + arg_sys (a)); + else + append (a.value); if (options) { @@ -2848,7 +2859,10 @@ namespace bpkg r += s + ' '; for (const string& v: a.config_vars) - r += v + ' '; + { + append (v); + r += ' '; + } r += '}'; } -- cgit v1.1