#1029264 coreutils: csplit: /regex/+1 matches past the end of the file?

Package:
coreutils
Source:
coreutils
Description:
GNU core utilities
Submitter:
наб
Date:
2023-01-20 13:57:04 UTC
Severity:
normal
#1029264#5
Date:
2023-01-20 13:53:30 UTC
From:
To:
Dear Maintainer,

Given the following (or any Debian changelog, really; I've annotated this one with line numbers tho):
-- >8 --
tzpfms (0.3.2-1~bpo11) bullseye; urgency=medium	1
	2
  * Rebuild for bullseye.	3
	4
 -- наб <nabijaczleweli@nabijaczleweli.xyz>  Sun, 04 Dec 2022 14:46:22 +0100	5
	6
tzpfms (0.3.2-1) unstable; urgency=medium	7
	8
  * New upstream version 0.3.2	9
  * Update upstream changelog	10
	11
 -- наб <nabijaczleweli@nabijaczleweli.xyz>  Sun, 04 Dec 2022 14:30:51 +0100	12
	13
tzpfms (0.3.1-1) unstable; urgency=medium	14
	15
  * New upstream version 0.3.1	16
  * Import upstream changelog	17
  * Only build documentation and depend on mandoc if !nodoc	18
  * Only (depend on) shellcheck if !nocheck	19
	20
 -- наб <nabijaczleweli@nabijaczleweli.xyz>  Sat, 29 Oct 2022 23:28:58 +0200	21
-- >8 --

These lines match /^ --/1:
  6
  13

So what on earth does this result mean:
-- >8 --
$ csplit w '/^ --/+1' {*}
166
203
317
0
$ head xx*
==> xx00 <==
tzpfms (0.3.2-1~bpo11) bullseye; urgency=medium	1
	2
  * Rebuild for bullseye.	3
	4
 -- наб <nabijaczleweli@nabijaczleweli.xyz>  Sun, 04 Dec 2022 14:46:22 +0100	5

==> xx01 <==
	6
tzpfms (0.3.2-1) unstable; urgency=medium	7
	8
  * New upstream version 0.3.2	9
  * Update upstream changelog	10
	11
 -- наб <nabijaczleweli@nabijaczleweli.xyz>  Sun, 04 Dec 2022 14:30:51 +0100	12

==> xx02 <==
	13
tzpfms (0.3.1-1) unstable; urgency=medium	14
	15
  * New upstream version 0.3.1	16
  * Import upstream changelog	17
  * Only build documentation and depend on mandoc if !nodoc	18
  * Only (depend on) shellcheck if !nocheck	19
	20
 -- наб <nabijaczleweli@nabijaczleweli.xyz>  Sat, 29 Oct 2022 23:28:58 +0200	21

==> xx03 <==
$ wc xx*
  5  22 166 xx00
  7  29 203 xx01
  9  48 317 xx02
  0   0   0 xx03
 21  99 686 total
-- >8 --

Notably, also:
-- >8 --
$ csplit w '/^ --/+1' {3}
csplit: ‘/^ --/+1’: match not found on repetition 3
166
203
317
0
$ csplit w '/^ --/+1' {2}
166
203
317
0
-- >8 --
Despite there being only two matches (<=> {1} => 3 files).

наб