emacs-bug-tracker
[Top][All Lists]
Advanced

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

[debbugs-tracker] bug#26879: closed (end-of-line issue with cygwin 4.4-1


From: GNU bug Tracking System
Subject: [debbugs-tracker] bug#26879: closed (end-of-line issue with cygwin 4.4-1 sed 4.4)
Date: Thu, 11 May 2017 17:59:02 +0000

Your message dated Thu, 11 May 2017 12:58:12 -0500
with message-id <address@hidden>
and subject line Re: bug#26879: end-of-line issue with cygwin 4.4-1 sed 4.4
has caused the debbugs.gnu.org bug report #26879,
regarding end-of-line issue with cygwin 4.4-1 sed 4.4
to be marked as done.

(If you believe you have received this mail in error, please contact
address@hidden)


-- 
26879: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=26879
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: end-of-line issue with cygwin 4.4-1 sed 4.4 Date: Thu, 11 May 2017 02:23:23 -0700
I've tested and searched and I can't figure this one out.

It's a simple filename quoting filter to handle Windows files
that contain blanks.  Easy stuff.

--- t.out ---
C:\Scan\i .2

--- sedtest.sh ---
#!/bin/bash
echo "1. simple string works"
fn="C:\Scan\i .2"
echo " $fn"
echo $fn   | sed -e "s/^/'/" -e "s/\$/'/"
echo " "
echo "2. against a cat file fails"
cat t.out  | sed -e "s/^/'/" -e "s/\$/'/"
echo " "
echo "3. against the file itself fails"
 sed -e "s/^/'/" -e "s/\$/'/" t.out
echo " "
echo "4. Hex dump of the file shows crlf termination"
od -xc t.out


--- sedtest output ---$ sedtest.sh
1. simple string works
 C:\Scan\i .2
'C:\Scan\i .2'

2. against a cat file fails
'C:\Scan\i .2

3. against the file itself fails
'C:\Scan\i .2

4. Hex dump of the file shows crlf termination
0000000    3a43    535c    6163    5c6e    2069    322e    0a0d
          C   :   \   S   c   a   n   \   i       .   2  \r  \n

==== Am I doing something wrong, or is this a bug? =====


--- End Message ---
--- Begin Message --- Subject: Re: bug#26879: end-of-line issue with cygwin 4.4-1 sed 4.4 Date: Thu, 11 May 2017 12:58:12 -0500 User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.0
tag 26879 notabug
thanks

On 05/11/2017 04:23 AM, Dick Dunbar wrote:
> I've tested and searched and I can't figure this one out.

Correcting the subject line, there is no such thing as cygwin 4.4 (yet)
- cygwin is only at 2.8.0.  Individual programs are versioned
independently from cygwin1.dll.  So your report is about the Cygwin
pre-built binary of sed, where that sed version is 4.4-1.

> 
> It's a simple filename quoting filter to handle Windows files
> that contain blanks.  Easy stuff.
> 
> --- t.out ---
> C:\Scan\i .2
> 
> --- sedtest.sh ---
> #!/bin/bash
> echo "1. simple string works"
> fn="C:\Scan\i .2"
> echo " $fn"

$fn has no carriage return.

> echo $fn   | sed -e "s/^/'/" -e "s/\$/'/"

So this places the ' immediately after the 2.

> echo " "
> echo "2. against a cat file fails"
> cat t.out  | sed -e "s/^/'/" -e "s/\$/'/"

cat preserves line-endings, as does sed.  $ matches ONLY \n (not \r\n)
when in binary mode.  So you are sticking the ' in between \r and \n.
Visually, the way the terminal displays that is that it prints 2, then
rewinds to the beginning of the line, then displays ' (on top of what
was already ' that you inserted at the beginning), and then finally
moves to the next line.

> echo " "
> echo "3. against the file itself fails"
>  sed -e "s/^/'/" -e "s/\$/'/" t.out

Same story.


> 
> ==== Am I doing something wrong, or is this a bug? =====

You are forgetting that sed does NOT ignore \r on binary files.

Cygwin sed used to blindly treat binary files in text mode, but that was
INTENTIONALLY changed in February, in a coordinated move with grep and
awk at the same time.  If you fail to read cygwin release notes, it's
your own fault for being caught off-guard when you do a blind update:
https://cygwin.com/ml/cygwin-announce/2017-02/msg00036.html

Cygwin's goal is to emulate Linux, and Linux has the same behavior (of
NOT ignoring \r by default).  If you want to ignore \r, then explicitly
do so, either by massaging your data, using something like:
 d2u file | sed ...
 tr -d '\r' < file | sed ...
Or, you can use a text-mode mount instead of a binary-mode mount for
hosting file (the cygwin list is a better resource for how to set up a
text-mode mount point).

As such, I'm closing this as not an upstream bug.  If you don't like the
intentional change in cygwin behavior, that's something you may want to
bring up on the cygwin list, but there's nothing we can do about it here.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


--- End Message ---

reply via email to

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