From 5a6b55fe64c586a7e695fb1e077be4c68db28dec Mon Sep 17 00:00:00 2001 From: Sami Laine Date: Mon, 14 Sep 2026 14:31:01 +0300 Subject: [PATCH] Properly escape cwd in singularity exec Handles paths with spaces better. Also interrupts the run if cd fails. --- envkernel.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/envkernel.py b/envkernel.py index 2ef74ad..8f2ec7a 100755 --- a/envkernel.py +++ b/envkernel.py @@ -636,7 +636,7 @@ def run(self): # In Singularity 2.4 at least, --pwd does not work when used # with --contain. This manually does it using a bash cd + exec. if ('-c' in unknown_args or '--contain' in unknown_args ) and args.pwd: - rest = ["bash", "-c", "cd %s"%os.getcwd() + " ; exec "+(" ".join(shlex.quote(x) for x in rest))] + rest = ["bash", "-c", "cd \"%s\""%os.getcwd() + " && exec "+(" ".join(shlex.quote(x) for x in rest))] cmd = [ 'singularity',