Hello,
Regarding nl command, I think that behaving like 'p' option is always
enabled even if I do not enable this option.
In other words, the number is not reset for each logical pages in the
default setting.
This behavior is far from a long time ago, but is it a bug?
Version of the testing command is “nl (GNU coreutils) 8.25.5-632ed”.
Example:
$ cat test.txt
\:\:\:
header line 1
\:\:
section 1; body line 1 (total 1)
section 1; body line 2 (total 2)
\:\:
section 2; body line 1 (total 3)
section 2; body line 2 (total 4)
\:\:
section 3; body line 1 (total 5)
section 3; body line 2 (total 6)
\:
footer line 1
$ nl test.txt
header line 1
1 section 1; body line 1 (total 1)
2 section 1; body line 2 (total 2)
3 section 2; body line 1 (total 3)
4 section 2; body line 2 (total 4)
5 section 3; body line 1 (total 5)
6 section 3; body line 2 (total 6)
footer line 1
Expected output:
header line 1
1 section 1; body line 1 (total 1)
2 section 1; body line 2 (total 2)
1 section 2; body line 1 (total 3)
2 section 2; body line 2 (total 4)
1 section 3; body line 1 (total 5)
2 section 3; body line 2 (total 6)
footer line 1
I made a patch for this issue.
diff --git src/nl.c src/nl.c
index a4a48bc..be1b197 100644
--- src/nl.c
+++ src/nl.c
@@ -286,8 +286,6 @@ proc_header (void)
{
current_type = header_type;
current_regex = &header_regex;
- if (reset_numbers)
- line_no = starting_line_number;
putchar ('\n');
}
@@ -298,6 +296,8 @@ proc_body (void)
{
current_type = body_type;
current_regex = &body_regex;
+ if (reset_numbers)
+ line_no = starting_line_number;
putchar ('\n');
}
Best Regards :)
KOBAYASHI, Takashi