2010-05-13 5 views
0

Je suis en train de stocker une chaîne multiligne dans une variable makelignes multiples en font

var=$(shell cat <<End-of-message \ 
-------------------------------------\ 
This is line 1 of the message.\ 
This is line 2 of the message.\ 
This is line 3 of the message.\ 
This is line 4 of the message.\ 
This is the last line of the message.\ 
-------------------------------------\ 
End-of-message) 


printit: 
    @echo ${var} 

Cela ne fonctionne pas, alors je me demande si cela est possible du tout. J'ai besoin de conserver les nouvelles lignes ici et shell les convertit dans des espaces. Aucune suggestion?

+0

Quelle que soit la raison pour laquelle vous ne pouvez pas utiliser le texte dans un fichier externe ou dans le fichier makefile? – AlG

Répondre

0

Que diriez-vous ceci:

define var 
@echo ------------------------------------- 
@echo This is line 1 of the message. 
@echo This is line 2 of the message. 
@echo This is line 3 of the message. 
@echo This is line 4 of the message. 
@echo This is the last line of the message. 
@echo ------------------------------------- 
endef 

printit: 
    ${var} 

ou ceci:

.PHONY: var 
var: 
    @echo ------------------------------------- 
    @echo This is line 1 of the message. 
    @echo This is line 2 of the message. 
    @echo This is line 3 of the message. 
    @echo This is line 4 of the message. 
    @echo This is the last line of the message. 
    @echo ------------------------------------- 

printit: var 
Questions connexes