Manolete Manolete - 7 months ago 30
Bash Question

Bash missing $(HOME) variable

I have been compiling an application using

for quite a while without any problems. Today, I realized that my
wasn't working any longer. A bit of debugging and I soon found out that
was not defined

$echo $(HOME)
-bash: HOME: command not found

I always thought that
could be used interchangeably. Is there a reason why a system could be configured to avoid the use of


It's ${HOME}, not $(HOME).

$(HOME) would expand to the output of a HOME command. Since there (probably) is no such command, you'll get an error message.

However, $(HOME) is the correct syntax in a Makefile. If you need help debugging your Makefile, you'll need to show us what's in it -- or, better, a small Makefile that exhibits the same problem. A make rule like:

        echo $(HOME)

should print the path of your home directory when you run make target.

In the shell, you can refer to the HOME variable as $HOME or as ${HOME}; the latter can avoid problems with adjacent tokens.

In a Makefile, you can use either $(HOME) or ${HOME}, but the $(HOME) form is more common. You can omit the parentheses only when the variable name is one character long (but even then you should use them for clarity). (Nobody has claimed that make is a model of clear and intuitive syntax.)