Skip to content

Backslashes in yq expression got halved #2561

@eternalphane

Description

@eternalphane

Describe the bug
When evaluating expression with backslashes in strings, the number of backslashes in output strings got halved.

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

Incorrect behavior (string in expression)

$ yq -Pn -oj '["\\","\\\\","\\\\\\","\\\\\\\\","\\\\\\\\\\","\\\\\\\\\\\\"]'
[
  "\\",
  "\\",
  "\\\\",
  "\\\\",
  "\\\\\\",
  "\\\\\\"
]
$ jq -n '["\\","\\\\","\\\\\\","\\\\\\\\","\\\\\\\\\\","\\\\\\\\\\\\"]'
[
  "\\",
  "\\\\",
  "\\\\\\",
  "\\\\\\\\",
  "\\\\\\\\\\",
  "\\\\\\\\\\\\"
]

Correct behavior (string from input)

$ yq -P -oj <<< '["\\","\\\\","\\\\\\","\\\\\\\\","\\\\\\\\\\","\\\\\\\\\\\\"]'
[
  "\\",
  "\\\\",
  "\\\\\\",
  "\\\\\\\\",
  "\\\\\\\\\\",
  "\\\\\\\\\\\\"
]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions