#1029119 coreutils: csplit: makes an empty file when an expression goes backwards, must error per POSIX

Package:
coreutils
Source:
coreutils
Description:
GNU core utilities
Submitter:
наб
Date:
2023-01-18 01:18:03 UTC
Severity:
normal
#1029119#5
Date:
2023-01-18 01:14:44 UTC
From:
To:
Dear Maintainer,

Quoth Issue 7 (and Issue 8 Draft 2.1), XCU, csplit, OPERANDS:
  An error shall be reported if an operand does not reference
  a line between the current position and the end of the file.

Why, then:
-- >8 --
$ seq 999 | csplit - /10/ /^0$/
18
csplit: ‘/^0$/’: match not found
3870
-- >8 --
but
-- >8 --
$ seq 999 | csplit - /10/ 2
18
0
3870
-- >8 --
?

Cf. NetBSD, which gets both right:
-- >8 --
$ seq 999 | csplit - /10/ /^0/
18
csplit: ^0: no match
$ seq 999 | csplit - /10/ 2
18
csplit: 2: can't go backwards
-- >8 --

Best,
наб