Skip to content

[Usage] How to pass an inline argument for singularity shell call? #2748

Answered by dtrudg
physicistsam asked this question in Q&A
Discussion options

You must be logged in to vote

This is a shell scripting issue, relating to the heredoc.

When you use a heredoc << 'EOF' then the quotes (or lack of) around the EOF bit control whether variable names will be subsituted.

Single quotes... value of FOO doesn't get to the container shell.

$ cat script.sh 
#!/bin/bash

FOO=BAR

singularity shell docker://alpine << 'EOF'
  echo FOO IS: $FOO
EOF

$ bash script.sh 
INFO:    Using cached SIF image
FOO IS:

No quotes around EOF... value of FOO does get to the container shell.

$ cat script.sh 
#!/bin/bash

FOO=BAR

singularity shell docker://alpine << EOF
  echo FOO IS: $FOO
EOF

$ bash script.sh 
INFO:    Using cached SIF image
FOO IS: BAR

See e.g. https://phoenixnap.com/kb/bas…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@physicistsam
Comment options

Answer selected by physicistsam
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants