以下是在我的shell脚本中创建p4标签的代码段
for i in $( echo TEST-01); do
p4 label -i << ENDOFLABEL
Label: $i
Options: unlocked
Description: label from Automation
View:
//depot/...
ENDOFLABEL
done
如下所示抛出错误;怎么了?
warning: here-document at line 125 delimited by end-of-file (wanted `ENDOFLABEL')
./p4_l.sh: line 150: syntax error: unexpected end of file
答案 0 :(得分:2)
此处文档的结束标记必须左对齐。
for i in $( echo TEST-01); do
p4 label -i << ENDOFLABEL
Label: $i
Options: unlocked
Description: label from Automation
View:
//depot/...
ENDOFLABEL
done
或者,如果您使用实际标签进行缩进,则可以在开始标签前使用减号:
for i in $( echo TEST-01); do
p4 label -i <<-ENDOFLABEL
Label: $i
Options: unlocked
Description: label from Automation
View:
//depot/...
ENDOFLABEL
done
Spaces不起作用。此处文档中的所有前导标签都将被删除。这解决了p4
在Label:
行等行之前不喜欢空格的问题。还有其他方法可以解决这些问题。一种是使用诸如X
之类的字母来标记“真实数据”的位置。开始:
sed 's/^[[:space:]]*X//' <<-ENDOFLABEL | p4 label -i
XLabel: $i
XOptions: unlocked
XDescription: label from Automation
XView:
X //depot/...
ENDOFLABEL
done
只有ENDOFLABEL行必须以缩进方式显示,如果需要,您可以在//depot/
行之前设置标签。