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

Redundant printing can occur when using null-input #2100

Open
echlebek opened this issue Jul 11, 2024 · 2 comments
Open

Redundant printing can occur when using null-input #2100

echlebek opened this issue Jul 11, 2024 · 2 comments
Labels

Comments

@echlebek
Copy link

echlebek commented Jul 11, 2024

Describe the bug

When using yq -n with assignment expressions, some expressions can cause the resulting document to be printed more than once.

Version of yq:

$ yq --version
yq (https://github.com/mikefarah/yq/) version v4.44.2

Installed via: go install

Command

$ yq -n '.a.b.c = "foo", .a.b.d = "bar", .a.b.e = "baz"'

Actual behavior

a:
  b:
    c: foo
    d: bar
    e: baz
a:
  b:
    c: foo
    d: bar
    e: baz

Expected behavior

a:
  b:
    c: foo
    d: bar
    e: baz

Additional context
Discovered while using yqlib to build a document dynamically, found a minimal reproduction quite quickly on the yq command-line application. I tried using the -P flag as well to see if that would mitigate it, but it did not.

@mikefarah
Copy link
Owner

Hey - try using | instead of , (comma is the union operator, collecting multiple yaml nodes together, whereas | takes the output of the LHS and pipes that into the right, building a single document.

@echlebek
Copy link
Author

Thanks, is this expected behaviour for the union operator then?

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