sed strips CRs

Earnie Boyd earnie@users.sourceforge.net
Sat Feb 11 17:20:00 GMT 2012


On Sat, Feb 11, 2012 at 5:06 AM, Corinna Vinschen wrote:
> On Feb 10 14:44, Earnie Boyd wrote:
>> On Fri, Feb 10, 2012 at 10:07 AM, Corinna Vinschen wrote:
>> > On Feb 10 08:02, Nellis, Kenneth wrote:
>> >> Cygwin 'sed' seems to be stripping CRs from its input.
>> >> Linux sed doesn't do this. Example:
>> >
>> > Try the -b option.
>>
>> By this I assume you to mean that the -b option opens the input file
>> in binary mode.  But the mount table the OP showed was already in
>> binary mode.  Does sed not take that into consideration, I.E. it
>> specifies the mode as a text file unless -b is specified, is this
>> correct?
>
> Yes.  By default files are fopened using the "rt" mode on systems
> supporting this mode.  This behaviour is hardcoded into upstream sed.

But on Linux I would expect the "t" to be ignored and the file is open
in "binary" mode anyway.  I.E. the sed process would receive the CR
for CRLF line endings.  And since the OP's file systems were binary
mode I would have expected it to have been the same.  Except that
Cygwin has created a documented exception to this for the case of
binary vs text mode being explicitly specified in the call.  So while
it is expected behavior as defined by Cygwin it is unexpected behavior
if I believe Cygwin to be similar in operation to Linux.

-- 
Earnie
-- https://sites.google.com/site/earnieboyd

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple



More information about the Cygwin mailing list