diff --git a/flytekit/extras/tasks/shell.py b/flytekit/extras/tasks/shell.py index ef9cd0c0e1..ec728feeee 100644 --- a/flytekit/extras/tasks/shell.py +++ b/flytekit/extras/tasks/shell.py @@ -76,17 +76,26 @@ def subproc_execute(command: typing.Union[List[str], str], **kwargs) -> ProcessR kwargs = {**defaults, **kwargs} - try: - # Execute the command and capture stdout and stderr - result = subprocess.run(command, **kwargs) - print(result.check_returncode()) - - if "|" in command and kwargs.get("shell"): + if kwargs.get("shell"): + if "|" in command: logger.warning( """Found a pipe in the command and shell=True. This can lead to silent failures if subsequent commands succeed despite previous failures.""" ) + if type(command) == list: + logger.warning( + """Found `command` formatted as a list instead of a string with shell=True. + With this configuration, the first member of the list will be + executed and the remaining arguments will be passed as arguments + to the shell instead of to the binary being called. This may not + be intended behavior and may lead to confusing failures.""" + ) + + try: + # Execute the command and capture stdout and stderr + result = subprocess.run(command, **kwargs) + result.check_returncode() # Access the stdout and stderr output return ProcessResult(result.returncode, result.stdout, result.stderr)