Skip to content

start of document aka 3 dashes aka --- are removed on Linux if file has CRLF line terminators #2532

@manero6

Description

@manero6

Describe the bug
yq removes the 3 dashes on Linux when file has CRLF line terminators.

This happens for example with files created on Windoze but modified on Linux.

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

Reproduce the bug
this works as expected:

echo -e "---\ntest_var: aaa" | file -

/dev/stdin: ASCII text
echo -e "---\ntest_var: aaa" | yq '.test_var = "bbb"'

---
test_var: bbb

this removes the 3 dashes:

echo -e "---\ntest_var: aaa" | sed 's/$/\r/' | file -

/dev/stdin: ASCII text, with CRLF line terminators
echo -e "---\ntest_var: aaa" | sed 's/$/\r/' | yq '.test_var = "bbb"'

test_var: bbb

al these ^M are the problem:

echo -e "---\ntest_var: aaa" | sed 's/$/\r/' | cat -A

---^M$
test_var: aaa^M$

Solution
The solution for me was to fix all those files with sed 's/\r//', as they in general create problems in bash.

Im opening an issue anyway, maybe other have the same problem without knowing.
Maybe this if fixable, or at least yq could print an error/msg about that.


Great CLI utility btw :) cheers

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions