【问题标题】:how make executable script visible to 'which' on osx?如何使可执行脚本对 osx 上的“哪个”可见?
【发布时间】:2014-04-26 21:28:57
【问题描述】:

要从命令行使用 lilypond,您应该创建一个脚本,对其进行 chmod,并将其位置放在 PATH 上(参见右侧列 here)。您应该使用 .profile 进行 PATH 更改,但这对我不起作用,所以我使用了 .bash_profile。

这行得通(为什么 .profile 不起作用?我应该更喜欢 .bashrc 吗?),但 which lilypond 看不到脚本,我认为原因与我看不到它的原因相同findExecutable 在 haskell 的 System.Directory 中。

是这样吗,我该如何解决?

【问题讨论】:

  • 在将更改添加到您的 .bash_profile 之后,您是获取它还是重新打开您的会话?
  • 您可能实际上想使用.bashrc(有关详细信息,请参阅此页面:joshstaiger.org/archives/2005/07/bash_profile_vs.html),但是为什么不将添加可执行文件目录的行发布到PATH 所以我们可以看看。
  • PATH="~/bin:${PATH}" export PATH 嗯,实际上 PATH 中的~ 不适用于which,即使它允许找到可执行文件。如果我将~ 替换为其写出的等价物,它工作正常。这是为什么?

标签: macos bash shell path


【解决方案1】:

Bash 不会在双引号内扩展 ~。请改用export PATH=~/bin:"$PATH"。

如果 ~/.bash_profile 和 ~/.profile 都存在,则 Bash 在作为交互式登录 shell 调用时只会读取 ~/.bash_profile。终端和 iTerm 2 打开新的 shell 作为登录 shell,所以 Bash 读取 ~/.bash_profile 而不是 ~/.bashrc。见http://www.gnu.org/software/bash/manual/html_node/Bash-Startup-Files.html。

【讨论】:

    猜你喜欢
    • 2016-08-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-05
    • 2015-02-14
    • 1970-01-01
    • 2010-11-16
    相关资源
    最近更新 更多