根据 bash 调用顺序,如果通过 ssh 调用非交互式、非登录的 bash shell,它应该是 source ~/.bashrc. 这适用于 OS X 附带的 Bash 3.2.48(1) 版本。
但是,当我安装 bash 4.2.8(2)-release 并将其设置为我的登录 shell 时,通过 ssh(例如ssh <host> <command>)执行命令不会获取我的~/.bashrc.
有谁知道出了什么问题,或者我如何解决这个问题?
小智 7
可能已经晚了,但我遇到了这个问题,我的解决方案是添加
if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
Run Code Online (Sandbox Code Playgroud)
到我的~/.bash_profile.
您可以bash使用该选项通过 ssh运行--login。就像这样:
ssh <host> bash --login -c "command"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4519 次 |
| 最近记录: |