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

Support env(XX)[] expressions #2071

Closed
mikefarah opened this issue Jun 15, 2024 Discussed in #2069 · 1 comment
Closed

Support env(XX)[] expressions #2071

mikefarah opened this issue Jun 15, 2024 Discussed in #2069 · 1 comment
Assignees
Labels

Comments

@mikefarah
Copy link
Owner

Discussed in #2069

Originally posted by djthornton1212 June 14, 2024
I've tried different syntax to splat an env() and feel like I'm missing something.

Examples:

Not working

list='["item1", "item2", "item3"]' yq --null-input 'env(list)[]'  # returns Error: bad expression, please check expression syntax
list='["item1", "item2", "item3"]' yq --null-input '[env(list)][]'  # nests the array in an array then splats the second level, returning me to where I began

Working:

list='["item1", "item2", "item3"]' yq --null-input 'env(list) | .[]' # pipe then splat
list='["item1", "item2", "item3"]' yq --null-input '[env(list)][][]' # double splat after nesting

edit:
I've also found that using the as operator allows for correct splatting... is that the word...

list='["item1", "item2", "item3"]' yq --null-input 'env(list) as $list | $list[]'

I guess I'm trying to understand if the working examples are the correct way or is there's another method I should be using.

Thanks,

@mikefarah mikefarah added the bug label Jun 15, 2024
@mikefarah mikefarah self-assigned this Jun 15, 2024
mikefarah added a commit that referenced this issue Jun 15, 2024
@mikefarah
Copy link
Owner Author

Fixed in v4.44.2

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