Bash Makefile尾部错误“;“未找到命令”;调用自定义shell函数时
我有一个简单的Makefile:Bash Makefile尾部错误“;“未找到命令”;调用自定义shell函数时,bash,git,shell,makefile,gnu-make,Bash,Git,Shell,Makefile,Gnu Make,我有一个简单的Makefile: define git_all ls --recursive --directory --color=never */.git \ | sed 's/\/.git//' \ | xargs --no-run-if-empty -
define git_all
ls --recursive --directory --color=never */.git \
| sed 's/\/.git//' \
| xargs --no-run-if-empty --max-procs=10 --replace={} git -C '{}' $1 || true
endef
gitpull:
@$(call git_all,pull -v)
“gitpull”规则应该检测Makefile所在文件夹下的子文件夹中的任何和所有存储库。例如:
Makefile
\- a/.git
\- b/.git
...
当我运行“makegitpull”时,脚本工作正常,但有一个小问题。如果存储库已经是最新的,则会出现以下奇怪的跟踪错误:
> make gitpull
make: Already: Command not found
make: *** [Makefile:xxx: gitpull] Error 127
我猜shell试图将文本“已经是最新的”解释为命令,但失败了。但为什么它一开始就这么做呢?我显然遗漏了一些东西,但是什么?您似乎对
$(shell…
的功能感到困惑。如果希望在运行目标时而不是在解析Makefile时发生这种情况,则需要取出$(shell…
)
而且
如果我能猜出你想做什么,可能是
define git-all
find . -type d -name '.git' -execdir sh -c 'cd ..; git -C $1' _ {} \;
endef
here:
$(call git-all,pull -v)
谢谢你的旁白。请随意提出一个更安全的替代方案。