diff --git a/compiler/config.py b/compiler/config.py index 36cbfb71f..e6a8fee07 100644 --- a/compiler/config.py +++ b/compiler/config.py @@ -38,6 +38,8 @@ SOCKET_BUF_SIZE = 8192 +BASH_VERSION = tuple(int(i) for i in os.getenv("PASH_BASH_VERSION").split(" ")) + ## ## Global configuration used by all pash components @@ -98,9 +100,6 @@ def load_config(config_file_path=""): with open(config_file_path) as config_file: pash_config = json.load(config_file) - # set configuration variables gotten dynamically - pash_config["bash_version"] = get_bash_version() - if not pash_config: raise Exception( "No valid configuration could be loaded from {}".format(config_file_path) @@ -177,7 +176,3 @@ def set_vars_file(var_file_path: str, var_dict: dict): global config config["shell_variables"] = var_dict config["shell_variables_file_path"] = var_file_path - -def get_bash_version(): - out = subprocess.run(["bash", "-c", "echo ${BASH_VERSINFO[@]}"], capture_output=True) - return tuple(int(v) for v in out.stdout.split(b" ")[:4]) diff --git a/compiler/pash_compilation_server.py b/compiler/pash_compilation_server.py index 9e36d8490..9d7f6ad0a 100644 --- a/compiler/pash_compilation_server.py +++ b/compiler/pash_compilation_server.py @@ -257,7 +257,7 @@ def compile_and_add(self, compiled_script_file, var_file, input_ir_file): variable_reading_start_time = datetime.now() # Read any shell variables files if present - vars_dict = env_vars_util.read_vars_file(var_file, config.config["bash_version"]) + vars_dict = env_vars_util.read_vars_file(var_file, config.BASH_VERSION) config.set_vars_file(var_file, vars_dict) variable_reading_end_time = datetime.now() diff --git a/compiler/pash_compiler.py b/compiler/pash_compiler.py index 568439224..04b5db9eb 100644 --- a/compiler/pash_compiler.py +++ b/compiler/pash_compiler.py @@ -57,7 +57,7 @@ def main_body(): runtime_config = config.config["distr_planner"] ## Read any shell variables files if present - vars_dict = env_vars_util.read_vars_file(args.var_file, config.config["bash_version"]) + vars_dict = env_vars_util.read_vars_file(args.var_file, config.BASH_VERSION) config.set_vars_file(args.var_file, vars_dict) log("Input:", args.input_ir, "Compiled file:", args.compiled_script_file) diff --git a/pa.sh b/pa.sh index 30922f029..609dad786 100755 --- a/pa.sh +++ b/pa.sh @@ -31,6 +31,9 @@ then exit fi +## get bash version for pash +export PASH_BASH_VERSION="${BASH_VERSINFO[@]:0:3}" + ## Create a temporary directory where PaSh can use for temporary files and logs export PASH_TMP_PREFIX="$(mktemp -d /tmp/pash_XXXXXXX)/"