#1035388 coreutils: pr: form feed behaves erratically, deviates from SVr4

Package:
coreutils
Source:
coreutils
Description:
GNU core utilities
Submitter:
наб
Date:
2023-05-02 16:03:04 UTC
Severity:
normal
#1035388#5
Date:
2023-05-02 15:58:27 UTC
From:
To:
Dear Maintainer,

As an extension, coreutils supports having the form feed character
act as "end of page in input file", and, like many pr extensions,
this is for compatibility with SysVr4.

Under SysVr4, FF in an input line splits it in twain:
the bit before the FF is a line on the current page,
the bit after  the FF is a line on the next page.
This is obvious and expected behaviour.

Indeed, they agree (sans #1034858):
-- >8 --
% { seq 56; printf 'a\fb\n'; } | pr | cat -sA
$
2023-05-02 17:46                                                  Page 1$
$
1$
2$
3$
4$
5$
6$
7$
8$
9$
10$
11$
12$
13$
14$
15$
16$
17$
18$
19$
20$
21$
22$
23$
24$
25$
26$
27$
28$
29$
30$
31$
32$
33$
34$
35$
36$
37$
38$
39$
40$
41$
42$
43$
44$
45$
46$
47$
48$
49$
50$
51$
52$
53$
54$
55$
56$
$
2023-05-02 17:46                                                  Page 2$
$
a$
$
2023-05-02 17:46                                                  Page 3$
$
b$
$

% { seq 55; printf 'a\fb\n'; } | pr | cat -sA
$
2023-05-02 17:52                                                  Page 1$
$
1$
2$
3$
4$
5$
6$
7$
8$
9$
10$
11$
12$
13$
14$
15$
16$
17$
18$
19$
20$
21$
22$
23$
24$
25$
26$
27$
28$
29$
30$
31$
32$
33$
34$
35$
36$
37$
38$
39$
40$
41$
42$
43$
44$
45$
46$
47$
48$
49$
50$
51$
52$
53$
54$
55$
a$
$
2023-05-02 17:52                                                  Page 2$
$
b$
$
-- >8 --

But not always. Here, coreutils pr eats the first line:
-- >8 --
% { seq 56; printf '\fb\n'; } | pr | cat -sA | tail
52$
53$
54$
55$
56$
$
2023-05-02 17:53                                                  Page 2$
$
b$
$
% { seq 56; printf '\fb\n'; } | ./a.out | cat -sA | tail
54$
55$
56$
$
May  2 17:53 2023   Page 2$
$
May  2 17:53 2023   Page 3$
$
b$
$
-- >8 --

And here the second:
-- >8 --
% { seq 56; printf 'a\f\n'; } | pr | cat -sA | tail
52$
53$
54$
55$
56$
$
2023-05-02 17:54                                                  Page 2$
$
a$
$
% { seq 56; printf 'a\f\n'; } | ./a.out | cat -sA | tail
54$
55$
56$
$
May  2 17:54 2023   Page 2$
$
a$
$
May  2 17:54 2023   Page 3$
$

% { seq 55; printf 'a\f\n'; } | pr | cat -sA | tail
48$
49$
50$
51$
52$
53$
54$
55$
a$
$
% { seq 55; printf 'a\f\n'; } | ./a.out | cat -sA | tail
50$
51$
52$
53$
54$
55$
a$
$
May  2 17:55 2023   Page 2$
$
-- >8 --

And here both:
-- >8 --
% { seq 56; printf '\f\n'; } | pr | cat -sA | tail
48$
49$
50$
51$
52$
53$
54$
55$
56$
$
% { seq 56; printf '\f\n'; } | ./a.out | cat -sA | tail
52$
53$
54$
55$
56$
$
May  2 17:55 2023   Page 2$
$
May  2 17:55 2023   Page 3$
$

% { seq 55; printf '\f\n'; } | pr | cat -sA | tail
47$
48$
49$
50$
51$
52$
53$
54$
55$
$
% { seq 55; printf '\f\n'; } | ./a.out | cat -sA | tail
49$
50$
51$
52$
53$
54$
55$
$
May  2 17:56 2023   Page 2$
$
-- >8 --

It's unclear to me why you'd want this, especially with a trivial-to-use
well-defined interface to copy.

Best,
наб