相关疑难解决方法(0)

为什么 bashrc 会检查当前 shell 是否是交互式的?

在我的拱安装,/etc/bash.bashrc以及/etc/skel/.bashrc包含这些行:

# If not running interactively, don't do anything
[[ $- != *i* ]] && return
Run Code Online (Sandbox Code Playgroud)

在 Debian 上,/etc/bash.bashrc有:

# If not running interactively, don't do anything
[ -z "$PS1" ] && return
Run Code Online (Sandbox Code Playgroud)

并且/etc/skel/.bashrc

# If not running interactively, don't do anything
case $- in
    *i*) ;;
      *) return;;
esac
Run Code Online (Sandbox Code Playgroud)

man bash然而,根据,非交互式 shell 甚至不读取这些文件:

   When  bash  is  started  non-interactively,  to run a shell script, for
   example, it looks for the variable …
Run Code Online (Sandbox Code Playgroud)

bash bashrc

79
推荐指数
3
解决办法
2万
查看次数

标签 统计

bash ×1

bashrc ×1