Project

General

Profile

Bug #13051

sed: lastline check does not work properly with empty files

Added by Andy Fiddaman 7 months ago. Updated 6 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
cmd - userland programs
Start date:
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:

Description

Sed has a bug where it does not treat a line as a 'last line' candidate if there are more files to process.

e.g.

% sed -n '$p' /etc/passwd
php:x:82:82:PHP User:/var/opt/ooce/php:

% sed -n '$p' /etc/passwd /dev/null
%

Related issues

Related to illumos gate - Feature #13061: Import sed tests from freebsdClosedAndy Fiddaman

Actions
#1

Updated by Electric Monk 7 months ago

  • Gerrit CR set to 855
#2

Updated by Andy Fiddaman 7 months ago

Before the changes in the attached gerrit review, some of the new tests fail:

[PASS] sed $p
[PASS] sed $p /tmp/tmp_27.dh3 /tmp/tmp_07.m42
[PASS] sed 3p /tmp/tmp_27.dh3 /tmp/tmp_07.m42
[PASS] sed 13p /tmp/tmp_27.dh3 /tmp/tmp_07.m42
[PASS] sed $p /tmp/tmp_27.dh3 /dev/null /tmp/tmp_07.m42
[PASS] sed 3p /tmp/tmp_27.dh3 /dev/null /tmp/tmp_07.m42
[PASS] sed 13p /tmp/tmp_27.dh3 /dev/null /tmp/tmp_07.m42
[PASS] sed $p /dev/null /tmp/tmp_27.dh3 /tmp/tmp_07.m42
[PASS] sed 3p /dev/null /tmp/tmp_27.dh3 /tmp/tmp_07.m42
[PASS] sed 13p /dev/null /tmp/tmp_27.dh3 /tmp/tmp_07.m42
[FAIL] sed $p /tmp/tmp_27.dh3 /tmp/tmp_07.m42 /dev/null
--- /tmp/tmp_34.dlc     Sun Aug 16 14:05:00 2020
+++ /tmp/tmp_1e.ai5     Sun Aug 16 14:05:00 2020
@@ -1,1 +1,0 @@
-z
[PASS] sed 3p /tmp/tmp_27.dh3 /tmp/tmp_07.m42 /dev/null
[PASS] sed 13p /tmp/tmp_27.dh3 /tmp/tmp_07.m42 /dev/null
[FAIL] sed $p /tmp/tmp_27.dh3 /dev/null /tmp/tmp_07.m42 /dev/null
--- /tmp/tmp_32.l44     Sun Aug 16 14:05:00 2020
+++ /tmp/tmp_1e.ai5     Sun Aug 16 14:05:00 2020
@@ -1,1 +1,0 @@
-z
[PASS] sed 3p /tmp/tmp_27.dh3 /dev/null /tmp/tmp_07.m42 /dev/null
[PASS] sed 13p /tmp/tmp_27.dh3 /dev/null /tmp/tmp_07.m42 /dev/null
[PASS] sed $p /dev/null /tmp/tmp_27.dh3 /dev/null /tmp/tmp_07.m42
[PASS] sed 3p /dev/null /tmp/tmp_27.dh3 /dev/null /tmp/tmp_07.m42
[PASS] sed 13p /dev/null /tmp/tmp_27.dh3 /dev/null /tmp/tmp_07.m42
[FAIL] sed $p /tmp/tmp_27.dh3 /tmp/tmp_07.m42 /dev/null /dev/null
--- /tmp/tmp_19.4ji     Sun Aug 16 14:05:00 2020
+++ /tmp/tmp_1e.ai5     Sun Aug 16 14:05:00 2020
@@ -1,1 +1,0 @@
-z
[PASS] sed 3p /tmp/tmp_27.dh3 /tmp/tmp_07.m42 /dev/null /dev/null
[PASS] sed 13p /tmp/tmp_27.dh3 /tmp/tmp_07.m42 /dev/null /dev/null
[FAIL] sed $p /tmp/tmp_27.dh3 /dev/null /dev/null /tmp/tmp_07.m42 /dev/null
--- /tmp/tmp_0e.1st     Sun Aug 16 14:05:00 2020
+++ /tmp/tmp_1e.ai5     Sun Aug 16 14:05:00 2020
@@ -1,1 +1,0 @@
-z
[PASS] sed 3p /tmp/tmp_27.dh3 /dev/null /dev/null /tmp/tmp_07.m42 /dev/null
[PASS] sed 13p /tmp/tmp_27.dh3 /dev/null /dev/null /tmp/tmp_07.m42 /dev/null
[PASS] sed $p /dev/null /tmp/tmp_27.dh3 /dev/null /dev/null /tmp/tmp_07.m42
[PASS] sed 3p /dev/null /tmp/tmp_27.dh3 /dev/null /dev/null /tmp/tmp_07.m42
[PASS] sed 13p /dev/null /tmp/tmp_27.dh3 /dev/null /dev/null /tmp/tmp_07.m42

and after, all tests pass:

% PATH=.:$PATH ksh ../../test/util-tests/tests/sed/sed_addr.ksh
[PASS] sed 3p /tmp/tmp_31.pp7
[PASS] sed $p /tmp/tmp_31.pp7
[PASS] sed 7,$p /tmp/tmp_31.pp7
[PASS] sed /d/p /tmp/tmp_31.pp7
[PASS] sed /a/p /tmp/tmp_31.pp7
[PASS] sed 5,7p /tmp/tmp_31.pp7
[PASS] sed 5,4p /tmp/tmp_31.pp7
[PASS] sed /a/,4p /tmp/tmp_31.pp7
[PASS] sed 0,/b/p /tmp/tmp_31.pp7
[PASS] sed 4,/a/p /tmp/tmp_31.pp7
[PASS] sed /d/,/g/p /tmp/tmp_31.pp7
[PASS] sed 3,+0p /tmp/tmp_31.pp7
[PASS] sed 3,+1p /tmp/tmp_31.pp7
[PASS] sed 5,+3p /tmp/tmp_31.pp7
[PASS] sed 6,+3p /tmp/tmp_31.pp7
[PASS] sed 7,+3p /tmp/tmp_31.pp7
[PASS] sed 8,+3p /tmp/tmp_31.pp7
[PASS] sed /a/,+1p /tmp/tmp_31.pp7
[PASS] sed /a/,+8p /tmp/tmp_31.pp7
[PASS] sed /a/,+9p /tmp/tmp_31.pp7
[PASS] sed 4,7!p /tmp/tmp_31.pp7
[PASS] sed 6,+3!p /tmp/tmp_31.pp7
[PASS] sed 7,+3!p /tmp/tmp_31.pp7
[PASS] sed 8,+3!p /tmp/tmp_31.pp7
[PASS] sed 4,7 { /e/b
                p
        } /tmp/tmp_31.pp7
[PASS] sed 4,+3 { /e/b
                p
        } /tmp/tmp_31.pp7
[PASS] sed $p
[PASS] sed $p /tmp/tmp_31.pp7 /tmp/tmp_2u.jut
[PASS] sed 3p /tmp/tmp_31.pp7 /tmp/tmp_2u.jut
[PASS] sed 13p /tmp/tmp_31.pp7 /tmp/tmp_2u.jut
[PASS] sed $p /tmp/tmp_31.pp7 /dev/null /tmp/tmp_2u.jut
[PASS] sed 3p /tmp/tmp_31.pp7 /dev/null /tmp/tmp_2u.jut
[PASS] sed 13p /tmp/tmp_31.pp7 /dev/null /tmp/tmp_2u.jut
[PASS] sed $p /dev/null /tmp/tmp_31.pp7 /tmp/tmp_2u.jut
[PASS] sed 3p /dev/null /tmp/tmp_31.pp7 /tmp/tmp_2u.jut
[PASS] sed 13p /dev/null /tmp/tmp_31.pp7 /tmp/tmp_2u.jut
[PASS] sed $p /tmp/tmp_31.pp7 /tmp/tmp_2u.jut /dev/null
[PASS] sed 3p /tmp/tmp_31.pp7 /tmp/tmp_2u.jut /dev/null
[PASS] sed 13p /tmp/tmp_31.pp7 /tmp/tmp_2u.jut /dev/null
[PASS] sed $p /tmp/tmp_31.pp7 /dev/null /tmp/tmp_2u.jut /dev/null
[PASS] sed 3p /tmp/tmp_31.pp7 /dev/null /tmp/tmp_2u.jut /dev/null
[PASS] sed 13p /tmp/tmp_31.pp7 /dev/null /tmp/tmp_2u.jut /dev/null
[PASS] sed $p /dev/null /tmp/tmp_31.pp7 /dev/null /tmp/tmp_2u.jut
[PASS] sed 3p /dev/null /tmp/tmp_31.pp7 /dev/null /tmp/tmp_2u.jut
[PASS] sed 13p /dev/null /tmp/tmp_31.pp7 /dev/null /tmp/tmp_2u.jut
[PASS] sed $p /tmp/tmp_31.pp7 /tmp/tmp_2u.jut /dev/null /dev/null
[PASS] sed 3p /tmp/tmp_31.pp7 /tmp/tmp_2u.jut /dev/null /dev/null
[PASS] sed 13p /tmp/tmp_31.pp7 /tmp/tmp_2u.jut /dev/null /dev/null
[PASS] sed $p /tmp/tmp_31.pp7 /dev/null /dev/null /tmp/tmp_2u.jut /dev/null
[PASS] sed 3p /tmp/tmp_31.pp7 /dev/null /dev/null /tmp/tmp_2u.jut /dev/null
[PASS] sed 13p /tmp/tmp_31.pp7 /dev/null /dev/null /tmp/tmp_2u.jut /dev/null
[PASS] sed $p /dev/null /tmp/tmp_31.pp7 /dev/null /dev/null /tmp/tmp_2u.jut
[PASS] sed 3p /dev/null /tmp/tmp_31.pp7 /dev/null /dev/null /tmp/tmp_2u.jut
[PASS] sed 13p /dev/null /tmp/tmp_31.pp7 /dev/null /dev/null /tmp/tmp_2u.jut
--- All sed_addr tests passed
#3

Updated by Andy Fiddaman 6 months ago

#4

Updated by Electric Monk 6 months ago

  • Status changed from In Progress to Closed
  • % Done changed from 0 to 100

git commit c6fc7f7b786ce47c35645054cdce73e83f39e7f3

commit  c6fc7f7b786ce47c35645054cdce73e83f39e7f3
Author: Andy Fiddaman <omnios@citrus-it.co.uk>
Date:   2020-08-25T20:59:45.000Z

    13051 sed: lastline check does not work properly with empty files
    Reviewed by: Robert Mustacchi <rm@fingolfin.org>
    Reviewed by: Dominik Hassler <hadfl@omniosce.org>
    Approved by: Gordon Ross <gordon.w.ross@gmail.com>

Also available in: Atom PDF