-
-
Notifications
You must be signed in to change notification settings - Fork 744
Description
Describe the bug
If the output from yq is a single string, then it will not be quoted properly in all cases.
If the string's content is the valid YAML encoding of something else (e.g. an integer, a map or a sequence), the output YAML will not encode that string, but the data encoded by that string when interpreted as a YAML value.
In other words: yq fails to detect if encoding a single string scalar as output, whether this string needs to be quoted. You could also say it treats a string scalar output as if you have given the -r flag in all cases.
Version of yq: 4.53.2
Operating system: linux
Installed via: docker
Input Yaml
Concise yaml document(s) (as simple as possible to show the bug, please keep it to 10 lines or less)
data1.yml:
"this: should really work"Command
The command you ran:
yq eval . data1.yaml
Actual behaviour
this: should really workThis should only happen, if we called yq with the -r option to enable raw output of scalars.
Expected behaviour
"this: should really work"Additional context
The problem does not depend on the input being top-level, but only on the output being a string scalar. It occurs the same for:
data2.yaml
foo: |
a: a
b: byq .foo data2.yaml
Which yields the output
a: a
b: bIt also happens if the output is a stream documents (if one of the documents is just a string scalar).
I could not reproduce this behaviour for other cases (such as when returning a sequence or map) and I haven't looked at the code yet to see whether this could be triggered in other cases.