简体   繁体   中英

How to run bash to var and use that in string in Makefile?

What I want is to run bash command docker-machine ip default put the result in a variable and use that variable in a string and export that variable to environment variable. But that doesn't work out as I expected.

Here's my Makefile so far.

IP := $(docker-machine ip default) 
export DATABASE_URL := "postgres://postgres@$(IP)/postgres"
test:
    echo $(DATABASE_URL)
    py.test tests

When I run make test I get

postgres://postgres@ /postgres

You need to indicate shell command:

IP := $(shell docker-machine ip default)
$(warning IP=$(IP))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM