Skip to content

csplit should always suppress lines based on line numbers #6126

@tertsdiepraam

Description

@tertsdiepraam

csplit has multiple ways to split files: based on regex, line numbers and more. The examples in this issue use this file:

seq 1 50 > 50.txt

If we use multiple line numbers in the wrong order, we get an error (both in uutils and GNU):

> csplit 50.txt 20 10
csplit: line number '10' is smaller than preceding line number, 20

So far so good. But, if we use a regex first and then a line number that is smaller than the number of the line where the regex matched we get in trouble:

# GNU
> csplit 50.txt /10/ 5 --suppress-matched
18
0
117

# uutils
csplit 50.txt /10/ 5 --suppress-matched`
18
0
120

The reason is that we seem to make a distinction between the less than and the equal case to determine whether the line should bee suppressed, but GNU doesn't.

cc @BenWiederhake

Found in #6114

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions