diff --git a/pkg/yqlib/encoder_properties.go b/pkg/yqlib/encoder_properties.go index a8d9e6c8..d615fa52 100644 --- a/pkg/yqlib/encoder_properties.go +++ b/pkg/yqlib/encoder_properties.go @@ -63,6 +63,11 @@ func (pe *propertiesEncoder) PrintLeadingContent(writer io.Writer, content strin } func (pe *propertiesEncoder) Encode(writer io.Writer, node *yaml.Node) error { + + if node.Kind == yaml.ScalarNode { + return writeString(writer, node.Value+"\n") + } + mapKeysToStrings(node) p := properties.NewProperties() err := pe.doEncode(p, node, "", nil) diff --git a/pkg/yqlib/properties_test.go b/pkg/yqlib/properties_test.go index 324a46d0..dcae4121 100644 --- a/pkg/yqlib/properties_test.go +++ b/pkg/yqlib/properties_test.go @@ -162,6 +162,14 @@ var propertyScenarios = []formatScenario{ expected: "mike: ${dontExpand} this\n", scenarioType: "decode", }, + { + description: "print scalar", + skipDoc: true, + input: "mike = cat", + expression: ".mike", + expected: "cat\n", + scenarioType: "roundtrip", + }, { description: "Roundtrip", input: expectedPropertiesUnwrapped,