3

foo.sh我的 Cygwin 目录中有脚本/usr/local/bin。我可以使用 bash 运行它mintty,但不能使用 bash。

当我开始时,情况如下:

foo.sh in mintty   -   WORKING
foo.sh in bash     -   NOT WORKING

然后我export PATH="${PATH}:/usr/local/bin"在我的.bashrc文件中添加了行。现在情况如下:

foo.sh in mintty   -   WORKING
foo.sh in bash     -   WORKING
however
bash -c foo.sh     -   NOT WORKING

我需要运行脚本的最后一种方法才能工作。我将在为 Windows 编译的可执行文件中使用它,因此该命令必须在cmd.

我的问题是:

  1. 如何设置变量PATH,使用bash -c
  2. 为什么默认/usr/local/bin不进去?PATH有什么理由不做我想做的事吗?
4

1 回答 1

0

.bashrc文件仅对非登录 shell 执行。对于这样的环境,我建议包括.bashrcfrom .bash_profile

echo '. "${HOME}/.bashrc"' >> ~/.bash_profile

这样,您.bashrc将包含在登录和非登录 shell 中。

于 2015-08-11T18:45:27.120 回答