Skip to content

Commit

Permalink
feat: add support for bash specific constructs as args
Browse files Browse the repository at this point in the history
  • Loading branch information
ejseqera committed Nov 2, 2023
1 parent c190d92 commit fafcea2
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion seqerakit/seqeraplatform.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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.
Expand Down

0 comments on commit fafcea2

Please sign in to comment.