coreutils icon indicating copy to clipboard operation
coreutils copied to clipboard

cat -n doesn't handle CRLF newline delimiters correctly

Open pfmoore opened this issue 1 year ago • 0 comments

This is with the latest version from github, built locally via cargo build --release --features windows

❯ coreutils printf "hello\r\nworld\r\nthere\r\n" | coreutils cat -n
     1  hello     2
world
there

Weirdly, looking at the output via xxd, the CRLF sequence is switched to LFCR...

❯ target\release\coreutils printf "hello\r\nworld\r\nthere\r\n" | target\release\coreutils cat -n | xxd
00000000: 2020 2020 2031 0968 656c 6c6f 2020 2020       1.hello
00000010: 2032 090a 0d77 6f72 6c64 0a0d 7468 6572   2...world..ther
00000020: 650a 0d                                  e..
❯ target\release\coreutils printf "hello\r\nworld\r\nthere\r\n" | xxd
00000000: 6865 6c6c 6f0d 0a77 6f72 6c64 0d0a 7468  hello..world..th
00000010: 6572 650d 0a                             ere..

pfmoore avatar Apr 17 '24 15:04 pfmoore