On Thu, Apr 26, 2007 at 10:06:40PM -0400, H.S. wrote:
> 
> In a makefile, if I have a rule to:
>       echo $(HOSTNAME);
> 
> it return a blank line, as if the variable is not set. Echoing $(HOME) 
> works, $(LANG) works, what is the deal with $(HOSTNAME)?

HOSTNAME is a variable that bash(1) sets - but it is *not* exported. You
can force it to be exported by
    $ export HOSTNAME
in your login script.

But ... relying on bash is decidedly non-portable. Why not use 
    `hostname`
instead?

> Echoing $(HOSTNAME) on a command prompt works though.

It does? Perhaps you're not using bash after all? I get:
    -bash: HOSTNAME: command not found

Note: the $(command) construct in bash is functionally identical to
`command` ...

Perhaps you meant ${HOSTNAME} (note the curly brackets) at the command
prompt?

-- 
Karl E. Jorgensen
[EMAIL PROTECTED]  http://www.jorgensen.org.uk/
[EMAIL PROTECTED]     http://karl.jorgensen.com
==== Today's fortune:
I have ways of making money that you know nothing of.
                -- John D. Rockefeller

Attachment: signature.asc
Description: Digital signature

Reply via email to