aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2021-04-09 16:30:10 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2021-04-09 16:30:10 +0200
commit39736221764168bcd9d0d926a4d4e99f3fe259e6 (patch)
tree8c5d28a913bdf9b9092589d98ef4f32f8920f567
parent42ae325b4a8c8957acfaae65b36928163a154dbc (diff)
Work around batch file issues
-rw-r--r--bbot/worker/worker.cxx27
1 files changed, 21 insertions, 6 deletions
diff --git a/bbot/worker/worker.cxx b/bbot/worker/worker.cxx
index 2105939..f012a34 100644
--- a/bbot/worker/worker.cxx
+++ b/bbot/worker/worker.cxx
@@ -2165,20 +2165,35 @@ startup ()
// Use the name=value notation for options to minimize the number of
// arguments passed to the environment setup executable. Note that the
- // etc/environments/default-*.bat scripts can only handle the limited
- // number of arguments.
+ // etc/environments/default-*.bat batch files can only handle a limited
+ // number of arguments. Also quote such options if the environment is a
+ // batch file to prevent them from being split into two arguments.
//
+ auto opt_val = [&pp] (const char* opt, const string& val) -> string
+ {
+#ifdef _WIN32
+ if (const char* e = path::traits_type::find_extension (
+ pp.effect_string ()))
+ {
+ if (icasecmp (e, ".bat") == 0)
+ return '"' + string (opt) + '=' + val + '"';
+ }
+#endif
+
+ return string (opt) + '=' + val;
+ };
+
if (ops.systemd_daemon ())
os.push_back ("--systemd-daemon");
if (ops.verbose_specified ())
- os.push_back ("--verbose=" + to_string (ops.verbose ()));
+ os.push_back (opt_val ("--verbose", to_string (ops.verbose ())));
if (ops.tftp_host_specified ())
- os.push_back ("--tftp-host=" + ops.tftp_host ());
+ os.push_back (opt_val ("--tftp-host", ops.tftp_host ()));
- os.push_back (string ("--env-script=") + pp.effect_string ());
- os.push_back ("--env-target=" + tg);
+ os.push_back (opt_val ("--env-script", pp.effect_string ()));
+ os.push_back (opt_val ("--env-target", tg));
// Note that we use the effective (absolute) path instead of recall since
// we may have changed the CWD.