|
From: | GNU bug Tracking System |
Subject: | [debbugs-tracker] bug#19899: closed (deleting lines of a file with sed - unexpected behaviour) |
Date: | Thu, 07 May 2015 02:22:02 +0000 |
Your message dated Wed, 6 May 2015 19:20:47 -0700 with message-id <address@hidden> and subject line Re: bug#19899: sed: fix mishandling of overlapping address ranges has caused the debbugs.gnu.org bug report #19899, regarding deleting lines of a file with sed - unexpected behaviour to be marked as done. (If you believe you have received this mail in error, please contact address@hidden) -- 19899: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=19899 GNU Bug Tracking System Contact address@hidden with problems
--- Begin Message ---Subject: deleting lines of a file with sed - unexpected behaviour Date: Wed, 18 Feb 2015 19:56:58 -0500 To whom it may concern,I noticed something odd while fooling around with sed. If you try to remove multiple line intervals (by number) from a file, but any interval specified later in the list is a subset of an interval earlier in the list, then an additional single line is removed after the specified (larger) interval.seq 10 > foo.txt sed '2,7d;3,6d' foo.txt 1 9 10
Expected output is:
1
8
9
10Additional tests:
For each additional redundant interval, another line is removed:
sed '2,7d;3,6d;4,5d' foo.txt
1
10Reversing the order of the intervals produces the expected result!
sed '3,6d;2,7d' foo.txt
1
8
9
10Specifying the intervals with '-e' produces the same result:
sed -e '2,7d' -e '3,6d' foo.txt
1
9
10Using different interval syntax has mixed results:sed -e '/2/,/7/d' -e '/3/,/6/d' foo.txt
1
8
9
10sed -e '2,7d' -e '/3/,/6/d' foo.txt
1
8
9
10
sed -e '/2/,/7/d' -e '3,6d' foo.txt
1
9
10Trailing list must be a subset for the additional line to be removed:
sed '2,5d;1,5d'
1
8
9
10sed '2,5d;2,6d'
1
8
9
10
sed'2,5d;2,5d'
1
9
10
Versions:
Breakage appears to have occurred in the 4.1 release. See the expected output for all cases in GNU sed 3.02 and 4.09 (as well as BSD sed (Mac OS X 10.2 Yosemite and /bin/sed on Solaris), but not in 4.15 and 4.21
.This issue and above information has been discussed on stack overflow:
stackoverflow.com/questions/28595574/deleting-lines-of-a-file-with-sed-unexpected-behaviourCheers,
Ethan
--- End Message ---
--- Begin Message ---Subject: Re: bug#19899: sed: fix mishandling of overlapping address ranges Date: Wed, 6 May 2015 19:20:47 -0700 On Tue, May 5, 2015 at 4:39 PM, Norihiro Tanaka <address@hidden> wrote: > On Mon, 4 May 2015 18:11:00 -0700 > Jim Meyering <address@hidden> wrote: > >> [resending, to @debbugs.gnu.org, not @bugs.gnu.org] >> >> Thank you Ethan for the report, and Norihiro for the patch. >> I've made adjustments to the patch, primarily to use the >> init.sh-based style of test case (permitting to add just one >> file for each test case, rather than 3 or more) and rewriting >> the commit log text and NEWS entry. >> >> Norihiro, please sanity-check before I push this. > > Thanks for review and ajustment. I confirmed them, and found no missing. > The test also does work expectedly. Thanks. Pushed.
--- End Message ---
[Prev in Thread] | Current Thread | [Next in Thread] |