mikefarah / yq

yq is a portable command-line YAML, JSON, XML, CSV, TOML and properties processor
https://mikefarah.gitbook.io/yq/
MIT License
11.29k stars 565 forks source link

Head comments retrieval incomplete from list of objects #2022

Open fpfuetsch opened 2 months ago

fpfuetsch commented 2 months ago

Describe the bug I have a list of yaml objects (each containing a head comment) from which I want to retrieve these comments. Unfortunately the comments are "empty" after as the first non-empty object.

Version of yq: 4.43.1 Operating system: mac Installed via: homebrew

Input Yaml

input.yaml:

# firstComment
---
# secondComment
key: value
---
# thirdComment
otherKey: otherValue
---
# fourthComment

Command The command you ran:

yq eval-all '. | head_comment' input.yaml

Actual behavior

firstComment
secondComment

Expected behavior

firstComment
secondComment
thirdComment
fourthComment
fpfuetsch commented 2 months ago

Probably a duplicate of #1007