I'm running a script (in tmuxinator) that tries to source another script (rvm). rvm explicitly does not allow sourcing from sh. I didn't think that would be a problem, because the shebang in the tmuxinator script is


but when I insert the code suggested by the rvm people to source rvm from a script,

if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then
  source "$HOME/.rvm/scripts/rvm"

-I get

sh: 6: [[: not found

Why is sh being used as the interpreter there? I've also used #!/usr/bin/zsh (which is the value of $SHELL in the interactive shell from which I called the script) and #!/usr/bin/env zsh, but they give the same complaint.

closed as off-topic by Michael Homer, Anthon, Ramesh, jasonwryan, jimmij Feb 1 '15 at 1:44

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – Michael Homer, Anthon, Ramesh, jasonwryan, jimmij
If this question can be reworded to fit the rules in the help center, please edit the question.

  • On the face of what you're saying, it should work, so you must have left something out. Post or link to the full script that you've added this snippet to, and tell us exactly how it's invoked. – Gilles Apr 12 '13 at 21:56
  • I've actually pared the script down to just what I posted and get the same result. The script is being called by Ruby, with the Kernel#exec method, but I can't find any reason why that should be forcing the use of sh. – bgates Apr 13 '13 at 4:06
  • ...until I looked at the documentation for Kernel#exec. "The standard shell means always “/bin/sh” on Unix-like systems". Well. – bgates Apr 13 '13 at 4:22

Does RVM operate in a /bin/sh context? This is likely the reason you're encountering this difficulty; the source'd script inherits the parent's interpreter. See: http://ss64.com/bash/source.html

. (source or dot operator)

Read and execute commands from the filename argument in the current shell context.

(emphasis mine)

  • I'm not reaching the source command, though. I hit the double bracket operator and sh complains about it because it's a bashism. – bgates Apr 13 '13 at 4:17
  • What's the value of ls -ld /bin/bash ? – laebshade Apr 25 '13 at 15:03
  • -rwxr-xr-x 1 root root 959168 Sep 19 2012 /bin/bash though as I said below the real problem was Ruby's exec command forcing the use of /bin/sh unless explicitly told to do otherwise. Thanks for the reminder about this question; I forgot to mark the solution I found as answered. – bgates Apr 26 '13 at 21:32

It looks like the problem was the script was called from Ruby with


and exec always operates in the context of /bin/sh, the shebang line in the called script apparently notwithstanding.

Changing to

exec('/bin/bash', '-c', script)


Not the answer you're looking for? Browse other questions tagged or ask your own question.