0

Trying to check whether or not a database is ready by it's HTTP status before executing the load_db script:

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

Everytime I run make load_db I keep getting the error:
/bin/bash: -c: line 0: syntax error near unexpected token `;'

abk
  • 309
  • 6
  • 15
  • 4
    Inside the Makefile, you'll need to escape the '$' in order for it to reach the shell interpreter. '$' becomes '$$': https://stackoverflow.com/a/29085684/86967 – Brent Bradburn May 14 '20 at 00:44

1 Answers1

1

In 'Makefile' the '$(something)' has special meaning - it will result to Make's variable something (or environment variable with the same name). You want to escape the '$', so that it will get passed to the shell. Usually, just using '$$' will do the trick.

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
dash-o
  • 13,723
  • 1
  • 10
  • 37