aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bpkg/pkg-build.cxx30
1 files 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 += '}';
}