#2: Split command before executing

This commit is contained in:
mtkennerly 2023-03-28 15:50:54 +08:00
parent 2c98d04fa2
commit 004550a190
No known key found for this signature in database
GPG key ID: E764BE00BE6E6408

View file

@ -1,10 +1,11 @@
import os import os
import shlex
import subprocess import subprocess
def run_command(command: str) -> str: def run_command(command: str) -> str:
print("Running command: {}".format(command)) print("Running command: {}".format(command))
result = subprocess.run(command, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) result = subprocess.run(shlex.split(command), check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
return result.stdout.decode("utf-8").strip() return result.stdout.decode("utf-8").strip()