使用linux csh脚本在许多子目录中执行makefile

Lou*_*zin 0 linux shell scripting csh makefile

我正在尝试编写一个csh脚本,它将在子目录中执行makefile.到目前为止我有这个:

find -maxdepth 2 -name 'Makefile' -print -execdir make \;

我遇到的问题是当我尝试运行它时出现以下错误:

find: The current directory is included in the PATH environment variable, which is insecure in combination with the -execdir action of find. Please remove the current directory from your $PATH (that is, remove "." or leading or trailing colons)

在这种情况下,我无法合理地更改$ PATH变量.关于变通方法的任何想法.

非常感谢和愉快的编码

Mad*_*ist 5

-execdir标志是GNU查找的一个特性,它的实现方式是抛出该错误,如果检测到它描述的情况则拒绝继续.没有选择find来避免该错误.所以,你可以修复PATH(你可以只为find命令本身做到这一点:

 PATH=<fixed-path> find -maxdepth 2 -name 'Makefile' -print -execdir make \;
Run Code Online (Sandbox Code Playgroud)

)或者不要-execdir像Basile所描述的那样使用.

呃...实际上是POSIX sh语法.是否csh支持?我没有用过csh这么长时间以至于我记不起来了,老实说这是一个如此糟糕的外壳,我不能去看看:-p :-)