See below - note that some of the commands (file, diff) are used to compare the files, others to compare the results, because I was expecting the same results from each file (cat, sort).
Should this unpredictability be considered a bug? Or are you expected to always check the format of a file before doing anything to it? i.e. should you make sure files are always in LF format if you are using any standard *nix utility in any context (except perhaps OSX - I haven't checked)?
Code: Select all
$ echo "S2
> S">lf
$ cp lf crlf
$ unix2dos crlf
unix2dos: converting file crlf to DOS format ...
$ cp lf cr
$ unix2mac cr
unix2mac: converting file cr to Mac format ...
$ file lf
lf: ASCII text
$ file crlf
crlf: ASCII text, with CRLF line terminators
$ file cr
cr: ASCII text, with CR line terminators
$ diff lf cr
1,2c1
< S2
< S
---
S S2
\ No newline at end of file
$ diff lf crlf
1,2c1,2
< S2
< S
---
> S2
> S
$ sort -V <lf
S
S2
$ sort -V <crlf
S2
S
$ sort -V <cr
S2
$ cat lf
S2
S
$ cat crlf
S2
S
$ cat cr
$ busybox cat cr
$ busybox cat crlf
S2
S
$ busybox cat lf
S2
S