yq icon indicating copy to clipboard operation
yq copied to clipboard

Add String interpolation

Open ivangreene opened this issue 2 years ago • 1 comments

Describe the bug String interpolation (with \(expression) syntax) doesn't work. The expression and surrounding \() is printed literally in the resulting string.

Version of yq: 4.22.1 Operating system: mac Installed via: homebrew

Input Yaml Concise yaml document(s) (as simple as possible to show the bug, please keep it to 10 lines or less) data1.yml:

value: 3

Command The command you ran:

yq '"value: \(.value)"' data1.yml

Actual behavior

value: \(.value)

Expected behavior

value: 3

Additional context Example of the expected behavior with jq:

$ jq '"value: \(.value)"' <<< '{"value": 3}'
"value: 3"

ivangreene avatar Mar 21 '22 15:03 ivangreene

I haven't actually added that feature in yet (and didn't know that you could do that in jq!) Until then, you can get similar result by either using string concatenation, or using envsubst

mikefarah avatar Mar 21 '22 22:03 mikefarah

Fixed in v4.43.1 :)

mikefarah avatar Mar 24 '24 00:03 mikefarah