我有这个制作食谱。
run_pipelines:
@[ "${filter}" ] || ( filter="."; ) && \
filter=$$(echo "$$filter" | sed -e 's/\./.*/g') && echo $${filter}"<3" && \
echo "\033[1;34m#######Running Pipelines for $${filter}#######\033[0m" && \
find v2/services -type f -regex ".*$${filter}.*.jsonnet" -print0 | \
xargs -r -0 -I {} bash -c 'echo -e "\033[1;32mjsonnet {} \033[0m"; jsonnet {} || exit $$?'
.PHONY: run_pipelines
它循环遍历所有 jsonnet 文件并运行 jsonnet 命令。 我希望它失败并在单个 jsonnet 命令失败后立即停止。
我尝试了一些方法,但没有任何效果。
如果您的
find
有 -quit
,则不要通过管道输入 xargs
和 bash
:
...
find v2/services -type f -regex ".*$${filter}.*.jsonnet" -print0 | \
xargs -r -0 -I {} bash -c 'echo -e "\033[1;32mjsonnet {} \033[0m"; jsonnet {} || exit $$?'
...
只需使用
find
的-exec
选项即可直接测试其返回:
...
find v2/services -type f -regex ".*$${filter}.*.jsonnet" \
-printf '\033[1;32mjsonnet %p \033[0m" \
\( -exec jsonnet {} \; -o quit \)
...