From 6315cfe974c7e9390ccee2f85da98a55b51bce0c Mon Sep 17 00:00:00 2001 From: Mike Farah Date: Sat, 28 Mar 2026 12:59:37 +1100 Subject: [PATCH] Update pkg/yqlib/operator_system.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- pkg/yqlib/operator_system.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/yqlib/operator_system.go b/pkg/yqlib/operator_system.go index e2d71203..f7173939 100644 --- a/pkg/yqlib/operator_system.go +++ b/pkg/yqlib/operator_system.go @@ -93,7 +93,12 @@ func systemOperator(d *dataTreeNavigator, context Context, expressionNode *Expre return Context{}, fmt.Errorf("system command '%v' failed: %w", command, err) } - result := strings.TrimRight(string(output), "\n") + result := string(output) + if strings.HasSuffix(result, "\r\n") { + result = result[:len(result)-2] + } else if strings.HasSuffix(result, "\n") { + result = result[:len(result)-1] + } newNode := candidate.CreateReplacement(ScalarNode, "!!str", result) results.PushBack(newNode) }