以下代码片段第 8 行中的点是什么意思,来自 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 中,.
是另一种拼写 source
的方式。所以这一行与此相同:
# 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
命令的位置一样。执行它的不同之处在于它可以设置alias
或定义function
或变量。
关于bash - bash脚本中点的用法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23085087/