String Interpolation Acts on Unselected Documents
Describe the bug
When selecting by document index and constructing a string, the ignored documents are still used for string construction, but without any content.
Version of yq: v4.48.1 Operating system: Debian via WSL on Windows Installed via: homebrew
Input Yaml
# test.yml
name: Alice
---
name: BobCommand The command you ran:
yq 'select(document_index==0) | "My name is \(.name)"' test.ymlActual behavior
The string is constructed twice, but because the second document was not selected, there is no content.
My name is Alice
My name isExpected behavior
I would have thought that the document that did not fit the select criteria would be dropped entirely.
My name is AliceAdditional context
This only seems to happen when filtering by document index. If the YAML document contains an array and we select on the array then pipe to a string, no strings are created for the unselected elements.
Perhaps I'm misunderstanding how the pipes or string interpolation are meant to be used. Maybe this is already documented somewhere, but I couldn't find anything. If this is intended behavior, a note in the documentation for interpolation or document filtering would be nice.
Source: mikefarah/yq