2

I have next rule in Makefile:

dbrestoretable:
    echo ${TABLE:-asdf}

When I run:

$ make dbrestoretable 
echo

But:

$ echo ${TABLE:-asdf}
asdf

Why default value asdf is not echoed in first case?

UPD

Specified duplicate speaks about how to use variable assigned in Makefile. And it does not answer why default value is not used

Look at this modified example:

dbrestoretable:
    echo ${TABLE:-asdf}
    echo ${TABLE}

Then run:

$ make dbrestoretable TABLE=mytable
echo 
echo mytable

$ make dbrestoretable
echo 
echo 

As you can see when I use ${TABLE:-asdf} it just return empty string. But I expect in first run mytable and second run asdf value to be echoed

Eugen Konkov
  • 22,193
  • 17
  • 108
  • 158
  • 2
    Actually it does tell you: the first `$` is expanded by make, not shell. Both `${name:-default}` and `${name/match/replace}` are implemented by shells (the latter only some shells) and not by make. To have shell do the expansion, you must use `$$` to tell make to send `$` to shell. – dave_thompson_085 May 10 '18 at 09:41

0 Answers0