gpt4 book ai didi

bash - Makefile中的Bash 'until'循环语法错误

转载 作者:行者123 更新时间:2023-12-03 08:25:14 24 4
gpt4 key购买 nike

在执行load_db脚本之前,尝试通过HTTP状态检查数据库是否准备就绪:

db:
## Startup database container, takes about 30 seconds to be available on port 7474

load_db: db
## Check status and break loop if successful
until $(curl --output /dev/null --silent --head --fail http://localhost:7474) ; do \
printf '.' ; \
sleep 5 ; \
done
## load database

每次我运行 make load_db时,我都会不断收到错误消息: /bin/bash: -c: line 0: syntax error near unexpected token `;'

最佳答案

在“Makefile”中,“$(something)”具有特殊含义-它将使Make的变量变为某物(或具有相同名称的环境变量)。您想转义“$”,以便将其传递给 shell 程序。通常,仅使用'$$'就可以解决问题。

load_db: db
## Check status and break loop if successful
until $$(curl --output /dev/null --silent --head --fail http://localhost:7474) ; do \
printf '.' ; \
sleep 5 ; \
done

关于bash - Makefile中的Bash 'until'循环语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61787284/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com