I have a process that prints some lines of text running in the background. If I start ssh, the newline characters don't work properly.
user@localhost:~$ { sleep 5; echo -e "1\n2\n3" ; } &
[1] 26215
user@localhost:~$ 1
2
3
user@localhost:~$ { sleep 5; echo -e "1\n2\n3" ; } &
user@localhost:~$ ssh localhost # quickly
user@localhost:~$ 1
2
3
I would expect 2 and 3 to start at the beginning of a newline regardless of whether ssh is running or not. Can someone explain what's happening here? Is there a way to fix things so newlines still work?
Oddly, if I throw some \r into the mix the newlines seem to work again, although I need to replace the default echo newline with a \r too.
user@localhost:~$ { sleep 5; echo -en "1\r\n2\r\n3\r\n" ; } &
[1] 7066
user@localhost:~$ 1
2
3