[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#19414: bug in sed
From: |
Bob Proulx |
Subject: |
bug#19414: bug in sed |
Date: |
Fri, 19 Dec 2014 20:06:06 -0700 |
User-agent: |
Mutt/1.5.23 (2014-03-12) |
Buchs, Kevin J. wrote:
> I am using sed, version 4.2.1 on a few different systems. What I have
> discovered is that inside a substitute command, a space alone is magically
> anchored at the start of the line in an anti-greedy match.
First, thank you for your bug report. Efforts to find and fix bugs
are appreciated. However...
Could you provide a test case *along with the output* that you are
expecting to see? Otherwise any of us that look are just going to see
what we expect and go, yep, looks okay to me.
> As an example, consider this input stream:
>
> a <-- leading space
> b c
> d e
> f g
Sure.
> Along with these one-liner invocations:
>
> sed -e 's/ *//'
> sed -e 's/[ ]*//'
Sure.
> sed -e 's/[[:space::]]*//'
Syntax error. You have two ':' characters where you almost certainly
wanted only one.
> sed -e 's/ ?//'
> sed -e 's/ +//'
Those look like you want extended regular expressions in those two
because of the use of ? and + but you are using the basic regular
expressions by the syntax. So those probably won't do what you want
but will work correctly.
> What seems to be happening is that the wildcard match gets anchored to the
> beginning of the line with a zero character hit.
>
> This case seems to apply not only to spaces but other characters.
Please provide the output you are expecting. This is what I get and
expect:
> a
> b c
> d e
> f g
sed -e 's/ *//'
a
b c
d e
f g
sed -e 's/[ ]*//'
a
b c
d e
f g
sed -e 's/[[:space:]]*//'
a
b c
d e
f g
sed -e 's/ \?//'
a
b c
d e
f g
sed -e 's/ \+//'
a
bc
de
fg
Those are all as expected. Are you expecting anything different?
Bob