From 5ae7c5afc0bc7daded9af1551214637704203610 Mon Sep 17 00:00:00 2001
From: Robert Izzard <r.izzard@surrey.ac.uk>
Date: Fri, 4 Feb 2022 20:32:30 +0000
Subject: [PATCH] add function to wrap command-line args in quotes

---
 binarycpython/utils/functions.py                   | 10 +++++++++-
 binarycpython/utils/population_extensions/slurm.py |  3 ++-
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/binarycpython/utils/functions.py b/binarycpython/utils/functions.py
index 363180ef6..d4aa94fcd 100644
--- a/binarycpython/utils/functions.py
+++ b/binarycpython/utils/functions.py
@@ -143,7 +143,6 @@ def get_ANSI_colours():
         for d, background_colour in background_colours.items():
             colours[c + " on " + d] = foreground_colour + background_colour
     colours["reset"] = Style.RESET_ALL
-
     return colours
 
 
@@ -1210,3 +1209,12 @@ def load_logfile(logfile: str) -> None: # pragma: no cover
         event_list.append(" ".join(split_line[9:]))
 
     print(event_list)
+
+def quotewrap(list):
+    """
+    Given a list, wrap each item in double quotes and return the new list
+    """
+    return ['"' + _x + '"' for _x in list]
+
+def command_string_from_list(list):
+    return ' '.join(quotewrap(list))
diff --git a/binarycpython/utils/population_extensions/slurm.py b/binarycpython/utils/population_extensions/slurm.py
index 4f1f4d3c8..ec5040c2a 100644
--- a/binarycpython/utils/population_extensions/slurm.py
+++ b/binarycpython/utils/population_extensions/slurm.py
@@ -306,7 +306,8 @@ class slurm:
                 ]
             )
 
-            grid_command = " ".join(grid_command)
+            # wrap command arguments in quotes
+            grid_command = command_string_from_list(grid_command)
 
             # make slurm script
             scriptpath = self.slurmpath("slurm_script")
-- 
GitLab