I have created a YAML "!eval" tag to evaluate embedded yq expressions.
yq '. ref $root | (.. | select(tag == "!eval")) |= (. tag = "" | . as $expr | $root | eval($expr))' t.yaml
x: 1
y: 2
z: !eval .x + .y
If the expression consists of undefined values sometimes the value is unchanged.
x: 1
y: 2
z: !eval .a + .b
In other cases the value is null, but also results in new keys being created for the undefined values.
x: 1
y: 2
z: !eval .a * .b
x: 1
y: 2
z: null
a: null
b: null
I am guessing this has something to do with the expression being evaluated to null versus something else.
I'm not sure if this is a bug, but it seems wrong that it would create new keys.
I have created a YAML "!eval" tag to evaluate embedded yq expressions.
If the expression consists of undefined values sometimes the value is unchanged.
In other cases the value is null, but also results in new keys being created for the undefined values.
I am guessing this has something to do with the expression being evaluated to null versus something else.
I'm not sure if this is a bug, but it seems wrong that it would create new keys.