Bash 'until' Makefile 中的循环语法错误
Bash 'until' loop syntax error in Makefile
在执行 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(或具有相同名称的环境变量)。您想要转义“$”,以便将其传递给 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
在执行 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(或具有相同名称的环境变量)。您想要转义“$”,以便将其传递给 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