From fe0ed2a8b158a0bf4f457eace63ec5747bf1f39e Mon Sep 17 00:00:00 2001 From: flintwinters Date: Wed, 17 Dec 2025 00:27:09 -0500 Subject: [PATCH] feat: Implement conditional quoting in shellVariablesEncoder - Modify doEncode method to check pe.prefs.UnwrapScalar. - If UnwrapScalar is true, output raw node.Value. - Otherwise, use quoteValue for shell-safe quoting. - This enables quote-free output for Kubernetes workflows when -r is used. --- pkg/yqlib/encoder_shellvariables.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/yqlib/encoder_shellvariables.go b/pkg/yqlib/encoder_shellvariables.go index 39236703..769252ba 100644 --- a/pkg/yqlib/encoder_shellvariables.go +++ b/pkg/yqlib/encoder_shellvariables.go @@ -57,7 +57,13 @@ func (pe *shellVariablesEncoder) doEncode(w *io.Writer, node *CandidateNode, pat // let's just pick a fallback key to use if we are encoding a single scalar nonemptyPath = "value" } - _, err := io.WriteString(*w, nonemptyPath+"="+quoteValue(node.Value)+"\n") + var valueString string + if pe.prefs.UnwrapScalar { + valueString = node.Value + } else { + valueString = quoteValue(node.Value) + } + _, err := io.WriteString(*w, nonemptyPath+"="+valueString+"\n") return err case SequenceNode: for index, child := range node.Content {