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: Dick Dunbar
Subject: bug#26879: end-of-line issue with cygwin 4.4-1 sed 4.4
Date: Thu, 11 May 2017 12:19:12 -0700

Thanks Eric,
but I'm a bit confused by the response.

sed is a stream editor;  introducing "binary files" as the reason for a
change
that leads to this failure doesn't sound right.

I can't forget what I never knew .. and changing "$" to mean something
other than the end of line because someone has a quarrel with Windows
ridiculous conventions doesn't make sense.

Reading the release notes I still would not have detected a failure like
this.

vi can properly handle crlf in cygwin;  why can't sed?
If it's a mode setting that's needed, than let me make the decision once
for my environment instead of facing these roadblocks in the future.

Changing something that has worked for years and then introducing
yet another filter (tr,d2u) to cover up for that change is silly.

I object to the "notabug" closure ... ok, if it's not a bug than it
certainly
is a "mental lapse in judgment".

That's the whole purpose of tools like cygwin;  to bridge the gap between
programming skills between unix and windows.  If the purpose of this change
is to make it painfully obvious that those differences exist ... for no
good purpose ...
I have to question the decision.

To bypass this problem, I simply modified the source of the pgm generating
the filenames to do the quoting.

I won't be touching sed again anytime soon.   Can't easily erase 30 years
of pgming habit.

If I need sed, I'll grab the source to sed and fix it myself.
Perhaps the busybox version works better, or I should permanently
switch to the MobaXterm platform instead.

Regarding version;  here are the first two lines of sed --version
$ sed --version
sed (GNU sed) 4.4
Packaged by Cygwin (4.4-1)

Ok, there is no cygwin 4.4-1 ... but there are hundreds of version
numbers listed in the components of a cygwin distribution.
The closest thing I have to a cygwin version is the setup program.


On Thu, May 11, 2017 at 10:58 AM, Eric Blake <address@hidden> wrote:

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


reply via email to

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