bash脚本中dot的用法

bash脚本中dot的用法,bash,Bash,下面代码片段第8行中的dot是什么意思,来自Mac OS X Mavericks终端中/etc/profile的源代码 1 # System-wide .profile for sh(1) 2 3 if [ -x /usr/libexec/path_helper ]; then 4 eval `/usr/libexec/path_helper -s` 5 fi 6 7 if [ "${BASH-no}" != "no" ]; then 8

下面代码片段第8行中的dot是什么意思,来自Mac OS X Mavericks终端中
/etc/profile
的源代码

  1 # System-wide .profile for sh(1)
  2 
  3 if [ -x /usr/libexec/path_helper ]; then
  4         eval `/usr/libexec/path_helper -s`
  5 fi
  6 
  7 if [ "${BASH-no}" != "no" ]; then
  8         [ -r /etc/bashrc ] && . /etc/bashrc
  9 fi

在bash中,
是拼写
源代码的另一种方法。所以这条线和这条一样:

# System-wide .profile for sh(1)

if [ -x /usr/libexec/path_helper ]; then
        eval `/usr/libexec/path_helper -s`
fi

if [ "${BASH-no}" != "no" ]; then
        [ -r /etc/bashrc ] && source /etc/bashrc
fi
source
将文件解释为内容包含在
source
命令的位置。执行它的区别在于,它可以设置别名或定义函数或变量

源文件时(通过键入源文件名或.filename 在命令行),文件中的代码行被执行为 它们被打印在命令行上。这尤其有用 使用复杂提示,允许将其存储在文件中并调用 通过寻找他们所处的文件


可能重复感谢您对动词“sourceed”的解释。从技术上讲,
source
是拼写
的另一种方式
是标准的POSIX命令
source
是一些Shell提供的更具可读性的同义词。但是,请注意,
source
不应在
.profile
中使用,这可能会被其他不理解
source
命令的POSIX兼容Shell读取。