variables and commands into makefile

whired123

Member
Joined
Nov 15, 2021
Messages
61
Reaction score
4
Credits
480
Code:
$ ls `xdg-user-dir TEMPLATES`
file1 file2 blabla...

OK

Code:
$ cat makefile
aaa = `xdg-user-dir TEMPLATES`
bbb = `ls $(aaa)`
#ccc = `other-command $(aaa)`
test:
    echo $(bbb)

$ make
echo `ls `xdg-user-dir TEMPLATES``
makefilexdg-user-dir TEMPLATES

Why?
 


Your make a has nested backticks.

This is being interpreted as
ls
xdg-user-dir TEMPLATES
`

As soon as the first backtick sees another backtick, that's the end of the command.

You can try this.

Code:
aaa = $(shell xdg-user-dir TEMPLATES)
bbb = $(shell ls $(aaa))
#ccc = $(shell other-command $(aaa))
test:
    echo $(bbb)
 
Here is an example command

Code:
result=`echo `date``

Do you know why this doesn't work?
That line has 4 back ticks in it, back ticks are examined in pairs. Whenever the interpreter sees
the first back tick, it looks for the very next back tick. That is the end of the evaluation.

It never makes it to the 3rd and 4th back tick.
 
Last edited:

Members online


Top