delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2006/06/27/13:28:32

X-Spam-Check-By: sourceware.org
Date: Tue, 27 Jun 2006 11:28:20 -0600 (MDT)
From: David Mastronarde <mast AT colorado DOT edu>
To: Dave <kilroyd AT googlemail DOT com>
cc: cygwin AT cygwin DOT com
Subject: Re: sed 4.1.5 adds extra CR with input file path in Windows format
In-Reply-To: <449EF283.80500@gmail.com>
Message-ID: <Pine.LNX.4.64.0606271119500.29629@druid.hvem.colorado.edu>
References: <Pine DOT LNX DOT 4 DOT 64 DOT 0606241421040 DOT 4607 AT druid DOT hvem DOT colorado DOT edu> <449EF283 DOT 80500 AT gmail DOT com>
MIME-Version: 1.0
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com


On Sun, 25 Jun 2006, Dave wrote:

> David Mastronarde wrote:
>> After upgrading sed from 4.1.4 to 4.1.5, I found that line endings were
>> being converted from CRLF to CRCRLF when the input file was specified
>> with a windows file path:
>> 
>> % sed -e 's/g5a/setname/g' < 'c:\cygwin\home\mast/sedtestin' > ! sedtestout
>> 
>> Converting the path to cygwin format eliminated the problem.
>> 
>
>> C:\cygwin                          /                         system 
>> textmode
>> C:\cygwin/bin                      /usr/bin                  system 
>> textmode
>> C:\cygwin/lib                      /usr/lib                  system 
>> textmode
>> C:\cygwin\usr\X11R6\lib\X11\fonts  /usr/X11R6/lib/X11/fonts  system 
>> binmode
>> .                                  /cygdrive                 system 
>> textmode,cygdrive
>
> Have a read of http://cygwin.com/cygwin-ug-net/using-textbinary.html
>
> Stepping through it:
> % sed -e 's/g5a/setname/g' < 'c:\cygwin\home\mast/sedtestin' > ! sedtestout
>
> rule b. sedtestin input will be read in binary mode. i.e it reads \r\n
>
> redirection of input is done in binmode from rule c.
> ditto output redirection.
>
> writing of the file is done in textmode due to your mounts (rule a). Hence 
> \r\n coming out of sed becomes \r\r\n.
>
> Try specifying the output file in MSDOS format, '.\sedtestout'.
>

Thanks for bringing the rules (back) to my attention.  Yes, it seems that 
the heart of the problem is that a file specified by a windows path is 
read in binary while the writing is to a textmode-mounted partition.  I 
never made the connection between the initial choice of line endings when 
running Cygwin setup and the mounting mode of the partitions.

I don't see the distinction between the redirection and the writing, and 
also setting CYGWIN to nobinmode has no effect, so rule c does not seem to 
be relevant.

But also, specifying output as '.\sedtestout' did NOT solve the problem, 
even with nobinmode in effect.  So rule b is governing the input but is 
not being applied on output.

David

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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019