相关疑难解决方法(0)

当我通过 ssh 运行非交互式命令时,为什么我的 .bashrc 会被读取

我在我的每个 bash 配置文件 ( ~/.bashrc, ~/.bash_profile, ~/.profile)前面加上了echo NAME_OF_FILE,即当我在~/.bashrc.

令我感到困惑的是,当我通过 ssh 运行命令时,为什么我得到并指出 ~/.bashrc 被包含在内。例如,如果我这样做:

ssh localhost echo hi
Run Code Online (Sandbox Code Playgroud)

我得到

.bashrc
hi
Run Code Online (Sandbox Code Playgroud)

为什么~/.bashrc在这种情况下采购?它不应该被引入,因为它应该运行一个非交互式 bash 会话吗?

事实上,ssh localhost tty让我得到一个“不是 tty”(前面是“.bashrc”,表明它~/.bashrc仍然来自)。

我已经将grep所有配置文件都~/.bashrc明确地用于命令采购,但没有人对此进行解释。

(我只有tty -s && shopt -q login_shell && [[ -r ~/.bashrc ]] && . ~/.bashrc在我的文件中,.bash_profile所以即使在交互式登录 shell 中我也能得到 '.bashrc',但这并不能解释 ssh 问题——我可以将其注释掉,我仍然得到与上述 ssh 示例相同的行为)

我该如何调试?

linux ssh terminal bash shell

4
推荐指数
1
解决办法
2811
查看次数

标签 统计

bash ×1

linux ×1

shell ×1

ssh ×1

terminal ×1