Skip to content

Prefix is printed if no hit with select(kind == ...) #2378

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

Open
hschlote opened this issue May 21, 2025 · 0 comments
Open

Prefix is printed if no hit with select(kind == ...) #2378

hschlote opened this issue May 21, 2025 · 0 comments
Labels

Comments

@hschlote
Copy link

Prefix is printed if no hit with select(kind == ...)
Following the example from https://mikefarah.gitbook.io/yq/recipes#export-as-environment-variables-script-or-any-custom-format I added a prefix to the output. Up to 4.45.2 all was fine but at least since 4.45.4 the prefix is printed if no match found

Version of yq: 4.45.4
Operating system: windows/....
Installed via: manually

Input Yaml
data1.yml:

# a: 1
# b: 2

# fruit:
#   - apple
#   - banana
#   - peach

Command
The command you ran:

yq '.. | (
  ( select(kind == "scalar" and parent | kind != "seq") |
      "scalar_" + key + "='\''" + . + "'\''" ),
  ( select(kind == "seq") |
      "seq_" + key + "=(" + (map("'\''" + . + "'\''") | join(",")) + ")")
)' data1.yml

Actual behavior

scalar_
seq_

Expected behavior

no output

Additional context
Uncomment scalars or sequence and all is fine.

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