我試圖在Make目標中用冒號分隔值拆分字符串。拆分制定規則中的字符串
當我嘗試在使用for循環,eval,shell的目標配方中拆分字符串時,我得到空白值。在那時我使用shell命令將字符串拆分到目標結果之外是正面的。
任何人都可以幫助我修復目標配方。
下面是片段。
notebooks=new:e7e45d89-94cc-4783-86c5-2236d9904a24 test:2af1d689-98c3-48f2-984d-2ea21c5135dd
j=new:e7e45d89-94cc-4783-86c5-2236d9904a24
f1=$(shell echo $j | cut -d: -f 1)
test1:
@for i in $(notebooks); \
do \
$(eval f=$(shell echo $i | cut -d: -f 1)) \
$(eval fid=$(shell echo $i | cut -d: -f 2)) \
echo $(f) $(fid) $(f1) ;\
done
輸出是
new
new
鑑於期望的輸出是
new e7e45d89-94cc-4783-86c5-2236d9904a24 new
test 2af1d689-98c3-48f2-984d-2ea21c5135dd new
感謝@MadScientist的解釋。 – user3273016