New line escape is not working correctly under MSYS shell

Hi,

I've noticed this strange issue on Windows (using the beta 4 and nightly).
I made this little test:

fn main() {
    println!("Hello!");
    println!("This is a simple test\n\rto check if the carriage\nreturn\nis working!");
}

As you can see I used a \n\r between "test" and "to check".
Now if I run the same executable under MSYS2 shell and normal Command Prompt shell I got two different results:

  • MSYS shell
  • Command Prompt shell

As you can see in MSYS shell the \n seems to be not translated in the right way, while surprisedly is managed in the right way (even without the \r) under Command Prompt shell.

Isn't windows new line \r\n?

Yes, you're right @Ygg01, but anyway this doesn't explain why the \n works correctly under Command Prompt, while under MSYS you need also the \r.

Also the Cargo output has the same issue under MSYS.

I think you are seeing the correct behavior in msys and the expected behavior in cmd.

If you just do \r, you start probably overwriting the beginning of the line.

###msys

  • \r puts the cursor at the start of the line
  • \n puts the cursor below the current cursor position.

###cmd
\n means "cursor position should be the beginning of the next line"

1 Like

I'd file a bug report for msys, I think it should output the same as the Windows console.