这是在我的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
这里文档的结束标记必须左对齐。
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
空格将无效。本文文档中的所有前导标签都将被删除。这样就解决了这样的问题,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/
如果需要,可以在该行之前使用制表符。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句