The /singularity script that is created from the %runscript section in the definition file has a default #!/bin/sh shebang instruction. It would be good to be able to select other shells, like the Bourne shell, maybe through a parameter in the definition file.
My use case, in particular, is the need to activate a conda environment inside the container by running
source activate <env_name>
The activate script from conda only supports bash. The workaround, at the moment, is to write something like:
%runscript
/bin/bash <<EOF
source activate <env_name>
echo "some code here"
EOF
But having the possibility of selecting the default shell would simplify and streamline the entry point script.
I think this is a good idea. Maybe we could parse the runscript for the presence of a #! in the first line and column. If it's there, we use that line as shebang. If it's not there we default to #!/bin/sh. Thoughts?
Hi, any chance that this feature will be considered for inclusion? It should be pretty easy to implement, I guess :)
Actually, I would be happy to contribute to the project implementing the feature myself.
For that I would welcome some hints of where I should look inside the code... I tried to figure it out myself but I think it's a bit involved... 馃槄
Whoops! The link I sent you above is actually for the startscript (new feature in 2.4). But whatever we do for the runscript (very next section) we should also do for the startscript. (Please also change the comment above the startscript section when you submit this PR.) Thank you!
Heya @robmosca! Did you still want to work on this? I actually have something coded up, but I've been holding off on pull request in case you still want to take a stab at it.
Most helpful comment
I think this is a good idea. Maybe we could parse the runscript for the presence of a
#!in the first line and column. If it's there, we use that line as shebang. If it's not there we default to#!/bin/sh. Thoughts?