Skip to content

Commit 2e0219c

Browse files
authored
fixing bash util (#779)
1 parent 966611b commit 2e0219c

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

langchain/utilities/bash.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,13 @@ def __init__(self, strip_newlines: bool = False):
1212

1313
def run(self, commands: Union[str, List[str]]) -> str:
1414
"""Run commands and return final output."""
15-
outputs = []
1615
if isinstance(commands, str):
1716
commands = [commands]
18-
for command in commands:
19-
try:
20-
output = subprocess.check_output(command, shell=True).decode()
21-
if self.strip_newlines:
22-
output = output.strip()
23-
outputs.append(output)
24-
except subprocess.CalledProcessError as error:
25-
return str(error)
26-
return outputs[-1]
17+
commands = ";".join(commands)
18+
try:
19+
output = subprocess.check_output(commands, shell=True).decode()
20+
except subprocess.CalledProcessError as error:
21+
return str(error)
22+
if self.strip_newlines:
23+
output = output.strip()
24+
return output

0 commit comments

Comments
 (0)