On 2/22/07, Sven Severus wrote:
But in a textmode mounted directory, 'echo peng >p.txt' creates
a 6 byte long file containing 'p' 'e' 'n' 'g' '\r' '\n'.
OK, exactly as expected. Now I thought, 'cat p.txt' would open
this file for reading in textmode, according to the default rule.
This is, what I expect, after reading the Cygwin FAQ:
"When processing in text mode, [...] written to the file [...]
you in fact get "Hello\r\n". Upon reading this combination,
the \r is removed [...]".
Why is it in fact not removed when reading with cat?
Because cat is required by posix to read in binmode. Try, for example:
$ echo peng >p.txt && read CO <p.txt && od -c <<<"$CO"
0000000 p e n g \n
0000005
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/