bug-gnu-utils
[Top][All Lists]
Advanced

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

Re: Sed bug ?


From: Eli Zaretskii
Subject: Re: Sed bug ?
Date: Tue, 13 Dec 2005 22:09:31 +0200

> Date: Tue, 13 Dec 2005 01:40:41 +0000
> From: Patrick Gaughan <address@hidden>
> 
> I recently downloaded the Win32 port of the UnxUtils hoping to be able 
> to use Sed on my
> Windows XP system in a DOS box. The first thing I tried was the EOLN 
> conversion, so
> that I could read the docs I had also downloaded. Most of these of 
> course only have LF as
> an EOLN as per Unix and are difficult to read.. A good "Hello World" 
> type try-out for my new
> utility I thought.  Using the conversion examples from  the Sed FAQ; i.e.
>     # Under DOS: convert Unix newlines (LF) to DOS format
>        sed 's/$//' file                     # method 1
>        sed -n p file                        # method 2
> was not successful so I read the FAQ several times to try and come up 
> with an explanation.

The Sed FAQ does not cover the Windows-specific aspects, so that is
not the best place to look for such information.

Most Windows ports of Sed do text-mode I/O, which means they strip CR
characters from EOLN on input and add them on output.  Thus, to
convert Unix to DOS EOLN format, simply tell Sed to pass every input
line to output:

     sed -e "" file > file.dos

> Having found nothing in there, but at least becoming familiar with the new
> concept (to me) of regular expressions I came up with
>        sed "s/.*/&\r/"
> which did work.

If this worked, then your port of Sed is one of the few which do not
use text-mode I/O.

> I then tried the 'sed -n p' example again on the converted text and this
> stripped out the CRs that I had inserted. So that, I presume, is why the 
> examples did not work,
> Sed is not inserting CRLF as EOLN, only LF.

It seems it strips CRs on input, but doesn't add them on output.
IMHO, that is not a good idea for a Windows port that wants to be a
good Windows citizen (i.e., to be able to produce files that other
Windows applications recognize and read as text files).

> Assuming that I am not missing something relevant in the FAQ and the
> other help pages I have now read, I presume this is not the intended
> behaviour for a Win32 port. It will be a real pain if it strips out
> the CRs from every document I try to edit.

I suggest to get a better port.  One place where you can find such a
port is the GnuWin32 project.  (UnxUtils is very old, anyway.)




reply via email to

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