Update pkg/yqlib/operator_system.go

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Mike Farah 2026-03-28 12:59:37 +11:00 committed by GitHub
parent 9a72c0f780
commit 6315cfe974
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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)
}