-
Notifications
You must be signed in to change notification settings - Fork 3
Description
There seems to have been and issue with newlines being translated by tty "magic" in the past.
In the past, having a tty on docker compose caused the error. But more recently, not having a tty causes the issue.
First tackled on 90f743f, it stated sources such as:
- docker outputs to standard out with added carriage return character moby/moby#8513
- https://unix.stackexchange.com/a/242814/332869
- https://superuser.com/q/1326853/352118
Testing
A simple method to cause the issue is:
docker run -it --rm ubuntu:latest bash -c 'echo {\"a\":5}' | jq
If the error does not occur, you will see
{
"a": 5
}
However, if it does occur you will see
{
"a": 5
}
The problem is able to be reproduced in windows, but only when using WSL as part of the experiment:
No error
Powershell: docker run -it --rm ubuntu:latest bash -c "echo -e '{\"a`":\n5}'" | jq
Command prompt: docker run -it --rm ubuntu:latest bash -c "echo '{"\""a"\"":5}'" | "c:\ProgramData\chocolatey\bin\jq.exe"
mingw: winpty bash; docker run -it --rm ubuntu:latest bash -c echo\ '{\"a\":5}' | jq
(Same results when using MS Terminal)
Error
WSL/Linux: docker run -it --rm ubuntu:latest bash -c echo\ '{\"a\":5}' | jq
Notes
It seems to have something to do with tty settings -opost or -onlcr sometimes, but the pattern is not clear, and sometimes doesn't involve them at all afaik. It's hard to tell for sure.