bug-sed
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#26879: end-of-line issue with cygwin 4.4-1 sed 4.4


From: Assaf Gordon
Subject: bug#26879: end-of-line issue with cygwin 4.4-1 sed 4.4
Date: Thu, 11 May 2017 17:59:57 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0

On 05/11/2017 04:29 PM, Eric Blake wrote:
> On 05/11/2017 03:13 PM, Assaf Gordon wrote:
>> If one wants the old sed behavior on cygwin (automatic
>> handling of CR/LF),
>> all that's needed is rebuilding sed from upstream source?
> 
> No. [...]
> The default upstream behavior has ALWAYS been to handle files in native
> mode (ie. open("r") - where the choice of text or binary is determined
> by the file system).  Downstream Cygwin sed USED to have a patch that
> overrode upstream behavior to do freopen(NULL, "rt", stdin)

I see. Thanks for explaining.

So the only systems where 'sed' does automatically strip CR/LF
are MingW/MSVC/MSDOS builds (and only there the "-b/--binary" option
makes a difference) ?

If so,
should we remove the "#ifdef __CYGWIN__" from sed's source code
since it now behaves exactly like gnu/linux ?
e.g.
https://git.savannah.gnu.org/cgit/sed.git/tree/sed/sed.c#n151
https://git.savannah.gnu.org/cgit/sed.git/tree/sed/execute.c#n560



> The drawback is that not all input is on a file system - if your input
> comes through a pipeline, you can't set the mount mode of a pipeline,
> and cygwin assumes all pipes are in binary mode.  But in those cases,
> you can always modify your pipeline to inject another filter to eat the
> \r before handing the data to sed.

To summarize, IIUC:
If someone uses new (post feb-2017) cygwin exclusively -
everything should "just work" and files have only '\n' line endings.

Line-Ending problems will occur of someone mixes old/new cygwin
tools or files (e.g. files created on old cygwin and used with newer
cygwin programs),
or
if mixing cygwin/non-cygwin tools.

Correct?

Thanks,
 - assaf


Out of curiosity (if anyone knows):
What does "Windows Subsystem For Linux" do with line-endings?







reply via email to

[Prev in Thread] Current Thread [Next in Thread]