bash - Makefile中的Bash'直到'循环语法错误
问题描述
在执行 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 的变量 something(或同名的环境变量)。您想转义“$”,以便将其传递给外壳。通常,只需使用 '$$' 就可以了。
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
推荐阅读
- android - 使用 FFmpeg 以特定帧率循环显示视频上的图像
- c++ - 相机没有抓取彩色图像
- javascript - 使用 JSON 对象作为图像源的属性时出错
- sql - 当列值相等时值,否则为 NULL 而 GROUPING
- python - 如何使用 Python 子进程捕获子进程的错误?
- javascript - 基于 JavaScript 的图像输入和键盘输出
- android - 当从editText发送触摸事件时自定义键盘设置可见性消失
- python - Python:如何从数据库中提取值(来自 yfinance)
- facet - Python altair - 具有多个变量的面线图
- html - 如何让 2 个图像在 div 中居中