Hello,
  we use CYGWIN in our application, and there are a lot of shell-script that use this sintax. In Windows environment, is normat that the End-Line terminator is CRLF e not LF.

Regarding your question:

1) Can you test your sed program with version 4.2.2 ?  
    R: Yes, same problems 

2) Does the problem still happen if you use the following?   sed '/^$/d'   
    R:: same problems

3.1. Which windows version are you using?
       Tested on Windows server 2012, Windows Server 2016, Windows 7 (all 64 bit)

3.2. Which cygwin version are you using?
       uname -a ->  CYGWIN_NT-10.0-WOW ITP-WDK2020 2.9.0(0.318/5/3) 2017-09-12 10:41 i686 Cygwin

3. Can you try the same sed command, but add the '--binary' flag,   if does it show the same results?
     R:: same problems


Regards

Mauro

Il giorno gio 25 gen 2018 alle ore 22:59 Assaf Gordon <assafgordon@gmail.com> ha scritto:
Hello,

On Thu, Jan 25, 2018 at 01:25:35PM +0000, Mauro Rigoni wrote:
> with the last x86_32 version of sed (windows platform) the
> following pattern
>
> sed '\?^$?D'
>
> don’t remove blank line from file if the file is in DOS format. In the
> previous version 2.2 this command working.

First,
Sed version 2.X is more than 20 years old. It is not the previous version.
The previous (and most common) version is version 4.2.2 from 2012.
Can you test your sed program with version 4.2.2 ?


Second,
A question about your sed program:
Does the problem still happen if you use the following?
   sed '/^$/d'

That is, regex with slashes (instead of '\?')
and using lower-case 'd' (simple delete command)
instead of 'D' (which is slightly more complicated
and deals with multilined buffers).


Third,
I do not have access to a windows machine, so a bit more information
is needed:
1. Which windows version are you using?
2. Which cygwin version are you using?
(I assume it is cygwin based on the version string)
3. Can you try the same sed command, but add the '--binary' flag,
   if does it show the same results?

For reference,
there is are two bug reports related to newlines with sed on windows.
https://bugs.gnu.org/25459 and https://bugs.gnu.org/26879 .

Specifically, note here https://debbugs.gnu.org/cgi/bugreport.cgi?bug=26879#12
where Eric Blake mentions that cygwin modified some internal
behaviour related to binary-vs-text files in February 2017.


regards,
 - assaf
--

Saluti
Mauro Rigoni