From a66901b00d25a43ddfc6da2d681711ecde4ef09a Mon Sep 17 00:00:00 2001 From: Intel A80486DX2-66 Date: Sun, 19 May 2024 20:29:13 +0300 Subject: [PATCH] b/c...py: use subprocess.run instead of os.system --- bytebeat_compiler.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/bytebeat_compiler.py b/bytebeat_compiler.py index 1e869f9..c9f3207 100644 --- a/bytebeat_compiler.py +++ b/bytebeat_compiler.py @@ -1,8 +1,9 @@ #!/usr/bin/python3 from argparse import ArgumentParser -from os import system, environ, makedirs +from os import environ, makedirs from os.path import exists, join as path_join +from shlex import split as command_line_split from sys import stdin, exit from typing import Dict, Union import subprocess @@ -229,7 +230,13 @@ if __name__ == "__main__": print("Compiling") # Let the system execute aliases by calling os.system - command = " ".join([CC, CFLAGS, INPUT_FILE, PATHS["fwrite_le"], "-o", - OUTPUT_FILE, "-I" + PATHS["include_directory"]]) - print(command, flush=True) - exit(system(command)) + command = [ + CC, + *command_line_split(CFLAGS), + INPUT_FILE, + PATHS["fwrite_le"], + "-o", OUTPUT_FILE, + "-I" + PATHS["include_directory"] + ] + print(" ".join(command), flush=True) + exit(subprocess.run(command).returncode)