我有一個打印消息的perl腳本。這個腳本被GNU make調用。在我的GNU make中,我想顯示由腳本打印出來的消息並將其存儲在一個變量中。如何將輸出字符串存儲到變量中並在控制檯中顯示
我正在這樣做。
result=`$(PERL) parse.pl report.log` #parse the report
echo $(result) #echo the message here
ifneq ($(strip $$(result)),) #check if message is empty
#if not empty, search for filepath string pattern and exit
echo filepath
exit 1
endif
但它沒有顯示來自parse.pl的字符串消息。
你有什麼要與捕捉到的線路後怎麼辦?顯示你的Makefile的一部分。你捕獲到一個shell變量中,但是然後試圖回顯一個makefile變量(即使你試圖回顯shell變量,那也不行,因爲make在單獨的shell進程中運行每行)。 – ysth
我已經更新了更多的細節。我還沒有想出如何對$ result執行regex,所以對任何提示都會很高興。 –