On 9/12/23 23:43, Oliver Webb wrote:
> ------- Original Message -------
> On Tuesday, September 12th, 2023 at 2:36 PM, Rob Landley <r...@landley.net> 
> wrote:
> 
> 
>> On 9/11/23 23:56, Oliver Webb via Toybox wrote:
>> 
>> > I have made a implementation of the 'csplit' command in about 160 lines of 
>> > code.

By the way, have you found anything that actually uses this? Busybox hasn't
bothered to implement it, and line selection is a trivial function of sed,
including regex support:

$ seq 1 15 | toybox sed -n -e '2,4p' -e '7,/../p'
2
3
4
7
8
9
10

Ahem:

$ seq 1 15 | toybox sed -ne '2,4wx00' -e '7,/../wxx1'
$ cat x00
2
3
4
$ cat xx1
7
8
9
10


> After some fiddling with the code
> that switches files and fprintf-s lines to them, I got the "%regexp%" rules 
> to work like they should:
> 
>   $ seq 10 | ./csplit - 2 %4% 7 -s
>   $ cat xx0*
>   1
>   4
>   5
>   6
>   7
>   8
>   9
>   10
>  
>   $ seq 10 | csplit - 2 %4% 7 -s
>   $ cat xx0*
>   1
>   4
>   5
>   6
>   7
>   8
>   9
>   10

I started to add the above to tests/csplit.test (because tests are always nice
to retain), but... isn't that the exact same test twice?

$ cat xx00
1
$ cat xx01
4
5
6
$ cat xx02
7
8
9
10

1 to 2 but not including 2. Then discard everything to %4% but not including 4.
Then the third one is everything FROM 7 through the end of the file, instead of
from current line _ending_ at 7...

I'm confused.

The gnu/dammit man page for this command is absolutely terrible. (And doesn't
have a "conforming to" section mentioning posix.) The posix command page is...
merely bad, but if you scroll down enough...

You can discard sections of input by regex, but not by line number?

The line_no number argument is absolute when first encountered (line X of the
file counting from the beginning), but relative when told to {repeat}, and you
have to have an absolute one before you can repeat it? And above it was both a
start of section and an end of section somehow?

I do not understand how this works. What am I missing here?

Rob
_______________________________________________
Toybox mailing list
Toybox@lists.landley.net
http://lists.landley.net/listinfo.cgi/toybox-landley.net

Reply via email to