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

evaluate command moves comments to a different line #2176

Open
guymeron opened this issue Oct 16, 2024 · 0 comments
Open

evaluate command moves comments to a different line #2176

guymeron opened this issue Oct 16, 2024 · 0 comments
Labels

Comments

@guymeron
Copy link

guymeron commented Oct 16, 2024

Describe the bug
evaluate command moves comments to a different line

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

Input Yaml
data1.yml:

line1: "aaa"
line2:
  - name: foo
    array:
      # comment1
      - key1: val1
        key2: val2
      # comment2

      # comment3
      - key1: val10
        key2: val20

Command

cat data1.yml |  yq eval .line2

Actual behavior

- name: foo
  array:
    # comment1
    - key1: val1
      key2: val2
    # comment3
    - key1: val10
      # comment2

      key2: val20

Expected behavior

- name: foo
  array:
    # comment1
    - key1: val1
      key2: val2
    # comment2

    # comment3
    - key1: val10        
      key2: val20

Additional context
It works OK when there is no empty line between the comments (line number 9).

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

1 participant