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

问题描述 投票:0回答:1

试图在执行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 `;'

bash shell makefile syntax-error gnu-make
1个回答
1
投票

在'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
© www.soinside.com 2019 - 2024. All rights reserved.