bug-sed
[Top][All Lists]
Advanced

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

bug#22427: Odd behaviour of sed with n/N and line ranges


From: Eric Blake
Subject: bug#22427: Odd behaviour of sed with n/N and line ranges
Date: Thu, 21 Jan 2016 13:02:12 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0

This message came up on the POSIX list today, claiming GNU sed has a bug:

On 01/21/2016 12:02 PM, Rob Landley wrote:
> On Thu, Jan 21, 2016 at 4:38 AM, Geoff Clare <address@hidden> wrote:
>> I'm seeing this with versions of sed derived from System V:
>>
>> $ printf '%s\n' a b | sed -e n -e '2s/b/c/'
>> a
>> c
>> $ printf '%s\n' a b | sed -e n -e '1,2s/b/c/'
>> a
>> b
> 
> Having recently implemented toybox sed from the posix spec, that's
> what my implementation is producing too.
> 
> You have to match the first line of a range in order to activate the
> range (numeric works same as /ascii/ that way). Since the above skips
> past the first line, you never activate the range, so later lines
> don't trigger the range contents either,
> 
> The gnu behavior is wrong. Replace the 1 with /a/ and the logic may be
> easier to follow
> 
> (But hey, at least the gnu guys finally fixed "sed p - -" segfaulting
> when it freed stdin the second time...)
> 
> Rob
> 
> 

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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