Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

yq doesn't count the first line if it's a comment #1354

Closed
daydy16 opened this issue Sep 22, 2022 · 1 comment
Closed

yq doesn't count the first line if it's a comment #1354

daydy16 opened this issue Sep 22, 2022 · 1 comment
Labels

Comments

@daydy16
Copy link

daydy16 commented Sep 22, 2022

Describe the bug
yq doesnt count the first line if it's a comment. I want to get the line number of a specific value in a file. If the first line is a comment, yq doesnt count the line.

#test123 
abc: 123 
test123: 123123 
#comment 
lalilu: lalilu

yq e '.lalilu | line' test123.yml --> 4 (instead of 5)

If i change the first line to a regular value everthing works fine:

a: abc 
#firstcomment 
abc: 123 
test123: 123123 
#comment 
lalilu: lalilu

yq e '.lalilu | line' test123.yml --> 6

Version of yq: 4.27.5
Operating system: linux and windows (tested on both)
Installed via: binary release and choco

maybe related to: #1181

@daydy16 daydy16 changed the title yq doenst count the first line if it's a comment yq doesn't count the first line if it's a comment Sep 22, 2022
@mikefarah
Copy link
Owner

By default yq pre-processes header comments - this was a bit of a annoying workaround added to fix a number of issues with the underlying go-yaml parser :/

However, that workaround has some unwanted side effects, this being one of them. You can disable the header processing by adding the flag --header-preprocess=false - then you'll get what you expect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants