The end marker of the here document must be left justified.
for i in $( echo TEST-01); do
p4 label -i << ENDOFLABEL
Label: $i
Options: unlocked
Description: label from Automation
View:
//depot/...
ENDOFLABEL
done
Or, if you use actual tabs for indentation, you can use a minus sign in front of the start label:
for i in $( echo TEST-01); do
p4 label -i <<-ENDOFLABEL
Label: $i
Options: unlocked
Description: label from Automation
View:
//depot/...
ENDOFLABEL
done
Spaces won't work. All leading tabs from the here document will be removed. This fixes the problem with p4
not liking spaces before lines such the Label:
line. There are other ways to handle such problems. One is to use a letter such as X
to mark where the 'real data' starts:
sed 's/^[[:space:]]*X//' <<-ENDOFLABEL | p4 label -i
XLabel: $i
XOptions: unlocked
XDescription: label from Automation
XView:
X //depot/...
ENDOFLABEL
done
Only the ENDOFLABEL line must be tab-indented, and you can have tabs before the //depot/
line if you need them.