Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

According to the bash invocation sequence, if a non-interactive, non-login bash shell is invoked via ssh, it's supposed to source ~/.bashrc. This works just fine with the OS X-shipped Bash 3.2.48(1)-release.

However, when I install bash 4.2.8(2)-release and set that as my login shell, executing a command via ssh (e.g. ssh <host> <command>) doesn't source my ~/.bashrc.

Does anybody know what's wrong, or how I can work around this?

share|improve this question
add comment

2 Answers

Probably way late, but I've run into this issue, and my solution was adding

if [ -f ~/.bashrc ]; then
   source ~/.bashrc
fi

to my ~/.bash_profile.

share|improve this answer
    
Unfortunately I don't have Bash 4 installed anymore so I can't test this out (I'm now using Fish), but I have some recollection of trying exactly that and having it not work. From what I recall, the problem is the shell was being invoked as a non-interactive, non-login shell, so it wasn't sourcing any of the usual user-controlled init scripts. –  Kevin Ballard Oct 11 '12 at 23:42
add comment

You can run bash through ssh with the --login option. Like so:

ssh <host> bash --login -c "command"
share|improve this answer
    
Not applicable in my case. SSH is being run by another utility (specifically, git). I have no control over its invocation. –  Kevin Ballard Apr 17 '11 at 3:35
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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