yq icon indicating copy to clipboard operation
yq copied to clipboard

Spurious newline added with `yq -i` when multiline strings are present

Open cbeck88 opened this issue 2 weeks ago • 0 comments

Describe the bug

When editing certain .yaml files in-place with yq that contain multiline strings, it adds newlines that don't belong. It adds more newlines every time it runs over these files.

Version of yq: 4.43.1 Operating system: linux Installed via: binary release

Input Yaml

data1.yaml:

image:
  tag: "0.55.3"
env:
  MM_CONFIGS: >-
    '{
      "params": {
        "a": "400",
        "b": "200"
      }
     }'

Command

yq eval ".image.tag = \"0.55.4\"" -i data1.yaml

Actual behavior

image:
  tag: "0.55.4"
env:
  MM_CONFIGS: >-
    '{

      "params": {
        "a": "400",
        "b": "200"
      }
     }'

Expected behavior

image:
  tag: "0.55.4"
env:
  MM_CONFIGS: >-
    '{
      "params": {
        "a": "400",
        "b": "200"
      }
     }'

Additional context

I haven't been able to find any good workarounds for this issue. Any tips short of a full fix would be greatly appreciated. Thanks

cbeck88 avatar Jun 19 '24 04:06 cbeck88