[comp.unix.shell] ed script "here" document in a Makefile

fitz@rpi.edu (01/07/91)

This shell script with an ed script splits my file into two new files:

ed foo <<E_O_F
1,/^ *References$/-1w foo.body
/^ *References$/+1,$w foo.ref
q
E_O_F

This makefile does the same thing for me:

EDSCRIPT= 1,/^ *References$$/-1w $(DOC).body@\
/^ *References$$/+1,$$w $(DOC).ref@\
q

ed:	$(DOC)
	echo '$(EDSCRIPT)' | tr @ '\012' | ed $(DOC)

My question: Can a makefile rule contain a "here" document like my
first example?  Please post tested solutions that use the standard
"ed", "sh", and "make".  Thanks!

Brian Fitzgerald

fitz@mml0.meche.rpi.edu (Brian Fitzgerald) (01/09/91)

In article <}7W^DZ_@rpi.edu> I meant to ask how to "embed" a "here"
document in a Makefile like this:

ed:	$(DOC)
	ed $(DOC) <<E_O_F
	1,/^ *References$/-1w $(DOC).body
	/^ *References$/+1,$w $(DOC).ref
	q
	E_O_F

With or without trailing backslashes, the second line gets run as a
shell command and I get "sh: *References-1w:" not found and so on.  A
certain net-guru (who uses four rows of the keyboard to spell his
name!) has given me strong reason to suspect that there is no portable
way to do this but that SysV "augmented" make may.  It's still up for
grabs if anyone is interested.

Brian Fitzgerald