yq
yq copied to clipboard
yq strips document separator when adding a comment
Describe the bug
I am trying to add a comment at the top of a multi-document yaml file. yq
unfortunately strips the first document separator line that is expected by downstream yaml linters I use.
Version of yq: 4.35.2 Operating system: linux Installed via: binary release
Input Yaml
data1.yml:
---
key: a
---
key: b
Command
yq eval-all 'select(documentIndex == 0) headComment|="A comment..."' data1.yml
Actual behavior
# I am a comment
key: a
---
key: b
Expected behavior
---
# I am a comment
key: a
---
key: b
or
# I am a comment
---
key: a
---
key: b
Having the same issue here, weird that it only applies to head_comment and when applied to the whole document (seems to work on a particular key)