Merge pull request #10107 from ChrisDryden/pr-omit-pagination

pr: add -T/--omit-pagination option
This commit is contained in:
Daniel Hofstetter
2026-01-08 16:43:43 +01:00
committed by GitHub
3 changed files with 25 additions and 1 deletions
+3
View File
@@ -30,6 +30,9 @@ pr-help-omit-header =
Write neither the five-line identifying header nor the five-line
trailer usually supplied for each page. Quit writing after the last line
of each file without spacing to the end of the page.
pr-help-omit-pagination =
omit page headers and trailers, eliminate any pagination
by form feeds set in input files
pr-help-page-length =
Override the 66-line default (default number of lines of text 56,
and with -F 63) and reset the page length to lines. If lines is not
+11 -1
View File
@@ -42,6 +42,7 @@ mod options {
pub const FIRST_LINE_NUMBER: &str = "first-line-number";
pub const PAGES: &str = "pages";
pub const OMIT_HEADER: &str = "omit-header";
pub const OMIT_PAGINATION: &str = "omit-pagination";
pub const PAGE_LENGTH: &str = "length";
pub const NO_FILE_WARNINGS: &str = "no-file-warnings";
pub const FORM_FEED: &str = "form-feed";
@@ -215,6 +216,13 @@ pub fn uu_app() -> Command {
.help(translate!("pr-help-omit-header"))
.action(ArgAction::SetTrue),
)
.arg(
Arg::new(options::OMIT_PAGINATION)
.short('T')
.long(options::OMIT_PAGINATION)
.help(translate!("pr-help-omit-pagination"))
.action(ArgAction::SetTrue),
)
.arg(
Arg::new(options::PAGE_LENGTH)
.short('l')
@@ -633,7 +641,9 @@ fn build_options(
let page_length_le_ht = page_length < (HEADER_LINES_PER_PAGE + TRAILER_LINES_PER_PAGE);
let display_header_and_trailer = !page_length_le_ht && !matches.get_flag(options::OMIT_HEADER);
let display_header_and_trailer = !page_length_le_ht
&& !matches.get_flag(options::OMIT_HEADER)
&& !matches.get_flag(options::OMIT_PAGINATION);
let content_lines_per_page = if page_length_le_ht {
page_length
+11
View File
@@ -641,3 +641,14 @@ fn test_separator_options_default_values() {
.pipe_in("a\nb\n")
.succeeds();
}
#[test]
fn test_omit_pagination_option() {
// -T/--omit-pagination omits headers/trailers and eliminates form feeds
// TODO: verify output matches GNU pr behavior (form feed elimination)
new_ucmd!().args(&["-T"]).pipe_in("a\nb\n").succeeds();
new_ucmd!()
.args(&["--omit-pagination"])
.pipe_in("a\nb\n")
.succeeds();
}