Skip to content
Snippets Groups Projects

feat(spack_operation): implement setup_spack_env functionality

1 file
+ 1
0
Compare changes
  • Side-by-side
  • Inline
+ 1
0
@@ -97,6 +97,7 @@ def copy_to_tmp(file_path: Path) -> Path:
def set_bashrc_variable(var_name: str, value: str, bashrc_path: str = os.path.expanduser("~/.bashrc"),
logger: logging = logging.getLogger(__name__)):
"""Update or add an environment variable in ~/.bashrc."""
value = value.replace("$", r"\$")
with open(bashrc_path, "r") as file:
lines = file.readlines()
pattern = re.compile(rf'^\s*export\s+{var_name}=.*$')