Skip to content

Commit

Permalink
Add reading bash version in pa.sh, not in python
Browse files Browse the repository at this point in the history
  • Loading branch information
BolunThompson committed Nov 13, 2024
1 parent 7c1d02c commit 6eb1e15
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 deletions.
9 changes: 2 additions & 7 deletions compiler/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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])
2 changes: 1 addition & 1 deletion compiler/pash_compilation_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion compiler/pash_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions pa.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)/"

Expand Down

0 comments on commit 6eb1e15

Please sign in to comment.