Support `env(XX)[]` expressions
mikefarah opened this issue · 1 comments
mikefarah commented
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 commented
Fixed in v4.44.2