aboutsummaryrefslogtreecommitdiff
path: root/bbot/worker/worker.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'bbot/worker/worker.cxx')
-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.