This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Why binary mode?


Eric Blake schrieb:
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?

The FAQ is outdated. Would you care to volunteer to help
maintain it? Reading the NEWS for coreutils, cat was changed
upstream in the last two years or so to always be binary-only,
to more closely comply with POSIX rules that state that
cat must operate on all file types, not just text files.
If cat used default mode, it would corrupt true binary
files that lived in text mounts.
OK, thanks for this hint...
And thanks too for your offer, to help maintaining the FAQ.
But unfortunately I have a boss who claims to use myself
at full capacity ;-> ... you know what I mean?


Lev Bishop schrieb:
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
I see, that's fine. I will use this construct instead of the command
expansion with cat. Thanks.


Norton Allen schrieb:
Which apparently means that the original doc he referred to (Cygwin
User's Guide, chapter "Text and Binary modes" ) should be updated. I
think the fact that cat reads in binmode is surprising (though it makes
sense if you think about it) so the behavior should be prominently
noted. Certainly the shell idiom of using cat to read text files is
widespread. Makes you wonder whether cat shouldn't have an option added
to read in text mode (that'd be an upstream question).
Lev Bishop schrieb:
It has been discussed to add a cygwin-local cat --text option, but
rejected on the basis that since it would be cygwin-only and
nonstandard, one might as well use the equally nonstandard d2u instead
of cat. I believe there was at one point some attempt to get such an
option upstream, but upstream resisted this. I'm sure this is
mentionned in the archives somewhere.
Thanks for your explanations.

Best regards,
Sven

--

Mit freundlichen Grüßen

Dipl. Inform. Sven Severus
Softwareentwicklung
----------------------------------------------------------
HIMA Paul Hildebrandt GmbH + CO KG
Abt: Entwicklung Software
Albert-Bassermann-Strasse 28
68782 Bruehl
Germany

Tel: +49 6202 709-289
Fax: +49 6202 709-299
E-Mail: s.severus@hima.com
Internet: www.hima.de


--


HIMA Paul Hildebrandt GmbH + Co KG, Postfach 12 61, 68777 Bruehl bei Mannheim
Kommanditgesellschaft, Sitz Bruehl, Deutschland - Registergericht Mannheim HRA 421017
Ust-ID: DE 144286400, St.Nr: 43038 00190

Persoenlich haftende Gesellschafterin Paul Hildebrandt Verwaltungsgesellschaft mbH, Sitz Bruehl, Deutschland - Registergericht Mannheim HRB 420588

Geschaeftsfuehrer: Dipl.-Betriebswirt Steffen Philipp, Dipl.-Kfm. Peter Swiczinsky




-- 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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]