[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: details required on wildcard function

From: Paul D. Smith
Subject: Re: details required on wildcard function
Date: Tue, 26 Feb 2002 10:27:09 -0500

%% address@hidden writes:

You don't need to send to the -admin address.  Thanks.

  bg> I find this peculiar thing happening in gmake. As per your mail
  bg> the env variable should not expanded.

And it's _not_ being expanded... by make! ;)

  bg> LISTROOT_FILENAME = /home/bhaskar/test.txt
  bg> REQFILE_LST := $(shell cat $(LISTROOT_FILENAME))
  bg> REQFILES := $(strip $(REQFILE_LST))
  bg> LIST_OF_FILES   := $(foreach file, $(REQFILES), $(wildcard $(file)))

  bg> default:
  bg>         @echo $(LISTROOT_FILENAME)
  bg>         @echo $(REQFILES)
  bg>         @echo $(LIST_OF_FILES)

  bg> address@hidden 332> echo $_ROOT
  bg> /usr
  bg> address@hidden 333> cat test.txt
  bg> /home/bhaskar $_ROOT /tmp

  bg> You can see the output of the REQFILES has been expanded to
  bg> /usr. The list REQFILES contains /usr init but this is not
  bg> transferred onto the wildcard function. I am wondering if the list
  bg> has the expanded list in it should not matter.

  bg> address@hidden 334> gmake
  bg> /home/bhaskar/test.txt
  bg> /home/bhaskar /usr /tmp
  bg> /home/bhaskar /tmp

The thing you're missing is that make passes its arguments to the
shell.  What make sends to the shell for "echo $(REQFILES)" is the
unexpanded text, just as it uses in wildcard; it sends this:

  echo /home/bhasker $_ROOT /tmp

Then, the shell runs that command and the _shell_ expands $_ROOT, just
as you'd expect, and the echo command actually prints what you see:
"/home/bhaster /usr /tmp".

Try rewriting your command to avoid shell expansion and you will see
what's happening:

        @echo '$(LISTROOT_FILENAME)'
        @echo '$(REQFILES)'
        @echo '$(LIST_OF_FILES)'

 Paul D. Smith <address@hidden>          Find some GNU make tips at:            
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist

reply via email to

[Prev in Thread] Current Thread [Next in Thread]