Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!ukc!stc!root44!gwc From: gwc@root.co.uk (Geoff Clare) Newsgroups: comp.unix.wizards Subject: Re: Make:defining macros with filenames that have '$' in them Message-ID: <1815@root44.co.uk> Date: 5 Mar 90 09:54:23 GMT References: <27177@cup.portal.com> <12219@smoke.BRL.MIL> <1990Feb23.174537.5490@smsc.sony.com> <1814@root44.co.uk> Reply-To: gwc@root.co.uk (Geoff Clare) Organization: UniSoft Ltd, London, England Lines: 38 In article <1814@root44.co.uk> I wrote: >DeadHead@cup.portal.com (Bruce M Ong) writes: >|I have to include a file with '$' in its name (i.e. abc.$cf) in >|a macro definition in Make. > >gwyn@brl.arpa (Doug Gwyn) writes: >|Did you try $$ ? > >dce@Sony.COM (David Elliott) writes: >| this isn't a simple question. After all, >|once Make tries to do anything with the filename, it uses the shell >|('$' is in the list of characters that force the use of sh), which >|will eat the $. > >Actually this IS a very simple question. Just make sure the $ is quoted >when it is passed to the shell: abc.'$$'cf or 'abc.$$cf' does the trick. I received some mail from David Elliott pointing out that the intention in the original question was for the macro to be usable as normal in dependency lines. My "single quotes" solution will only work where the macro is used in commands - if the macro is used in a dependency line, "make" will look for a file with single quotes in the name. I apologise for overlooking that requirement, however my answer is still basically the same: make sure the $ is quoted when passed to the shell. A way to do this, which allows the macro to work correctly in dependency lines, is to use a shell variable to "hide" the $ in commands, for example: FILES = abc.$$cf abd.$$cf all: $(FILES) files='$(FILES)'; cat $$files -- Geoff Clare, UniSoft Limited, Saunderson House, Hayne Street, London EC1A 9HH gwc@root.co.uk (Dumb mailers: ...!uunet!root.co.uk!gwc) Tel: +44-1-315-6600 (from 6th May 1990): +44-71-315-6600