From fafcea28113f43903bda01c1df8cb9c1cd3cf4b0 Mon Sep 17 00:00:00 2001 From: ejseqera Date: Thu, 2 Nov 2023 11:19:00 -0400 Subject: [PATCH] feat: add support for bash specific constructs as args --- seqerakit/seqeraplatform.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/seqerakit/seqeraplatform.py b/seqerakit/seqeraplatform.py index fd4853a..3cc8486 100644 --- a/seqerakit/seqeraplatform.py +++ b/seqerakit/seqeraplatform.py @@ -72,8 +72,11 @@ def _construct_command(self, cmd, *args, **kwargs): # Checks environment variables to see that they are set accordingly def _check_env_vars(self, command): full_cmd_parts = [] + shell_constructs = ["|", ">", "<", "$(", "&", "&&", "`"] for arg in command: - if "$" in arg: + if any(construct in arg for construct in shell_constructs): + full_cmd_parts.append(arg) + elif "$" in arg: for env_var in re.findall(r"\$\{?[\w]+\}?", arg): if re.sub(r"[${}]", "", env_var) not in os.environ: raise EnvironmentError( @@ -82,6 +85,7 @@ def _check_env_vars(self, command): full_cmd_parts.append(arg) else: full_cmd_parts.append(shlex.quote(arg)) + # print(f"full_cmd_parts before join: {full_cmd_parts}") return " ".join(full_cmd_parts) # Executes a 'tw' command in a subprocess and returns the output.