加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

macos – 在OS X上的Terminal.app中打开BASH shell时,如何设置PA

发布时间:2020-12-16 01:45:29 所属栏目:安全 来源:网络整理
导读:什么启动脚本 – 按照它们被调用的顺序 – 在OS X上的Terminal.app中打开BASH shell时设置PATH变量? 解决方法 我找到了罪魁祸首.秘诀是/usr/libexec / path_helper它在文件/ etc / paths和目录/etc/paths.d/中查找. 第一个bash源/ etc / profile执行以下代
什么启动脚本 – 按照它们被调用的顺序 – 在OS X上的Terminal.app中打开BASH shell时设置PATH变量?

解决方法

我找到了罪魁祸首.秘诀是/usr/libexec / path_helper它在文件/ etc / paths和目录/etc/paths.d/中查找.

第一个bash源/ etc / profile执行以下代码:

if [ -x /usr/libexec/path_helper ]; then
    eval `/usr/libexec/path_helper -s`
    # The above line is the secret sauce,so to say...
    # First is adds default PATH values from the file /etc/paths
    # Then all files in the /etc/paths.d/ directory are read and directories listed
    # in each file (one per line) are appended to PATH
fi

if [ "${BASH-no}" != "no" ]; then
    [ -r /etc/bashrc ] && . /etc/bashrc
fi

下一个bash查找?/ .bash_profile,?/ .bash_login和?/ .profile.

列出这些步骤,PATH构建如下:

>文件/ etc / paths中的目录被添加到PATH中>目录/etc/paths.d/中的文件中列出的目录将附加到PATH – 注意,这些目录是附加的而不是前置的.>各种PATH = {DIR_2_ADD}:我的?/ .bash_profile和?/ .bashrc文件中的“${PATH}”语句前置PATH

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读