tags:

views:

38

answers:

1

I am trying to force make file to display next string:

"Please execute next commands:
setenv PATH /usr/local/greenhills/mips5/linux86:$PATH"

The problem is with "$PATH". Command

@echo "setenv PATH /usr/local/greenhills/mips5/linux86:$PATH"

cause a result

"setenv PATH /usr/local/greenhills/mips5/linux86:ATH"

any combinations of escape characters, quotes, "$(shell echo " didn't get required results...

Any suggestions?

+1  A: 

The make uses the $ for its own variable expansions. E.g. single character variable $A or variable with a long name - ${VAR} and $(VAR).

To put the $ into a command, use the $$, for example:

all:
  @echo "Please execute next commands:"
  @echo 'setenv PATH /usr/local/greenhills/mips5/linux86:$$PATH'

Also note that to make the "" and '' (double and single quoting) do not play any role and they are passed verbatim to the shell. (Remove the @ sign to see what make sends to shell.) To prevent the shell from expanding $PATH, second line uses the ''.

Dummy00001
Thank you, you gave me the direction! @echo "setenv PATH /usr/local/greenhills/mips5/linux86:$$PATH"case to whole $PATH to be printed, but @echo 'setenv PATH /usr/local/greenhills/mips5/linux86:$$PATH' do the job!
BaruchLi
Because, as I have noted the `""` and `''` are passed to the shell. Inside the `""` shell would expand the `$PATH`, but not inside the `''`.
Dummy00001
@Dummy00001. Thanks for the reminder it's been soooo long since I used make
Steve Weet
To be perfectly honest, I always forget the bit myself and at first do the same mistake too ;)
Dummy00001