Skip to content

Commit ce8c8d5

Browse files
authored
pr: add default values for -s and -S separator options (uutils#10073)
* pr: add default values for -s and -S separator options * pr: fix -S default value to space, simplify test
1 parent cc6414e commit ce8c8d5

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

src/uu/pr/src/pr.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,14 +276,18 @@ pub fn uu_app() -> Command {
276276
.short('s')
277277
.long(options::COLUMN_CHAR_SEPARATOR)
278278
.help(translate!("pr-help-column-char-separator"))
279-
.value_name("char"),
279+
.value_name("char")
280+
.num_args(0..=1)
281+
.default_missing_value("\t"),
280282
)
281283
.arg(
282284
Arg::new(options::COLUMN_STRING_SEPARATOR)
283285
.short('S')
284286
.long(options::COLUMN_STRING_SEPARATOR)
285287
.help(translate!("pr-help-column-string-separator"))
286-
.value_name("string"),
288+
.value_name("string")
289+
.num_args(0..=1)
290+
.default_missing_value(" "),
287291
)
288292
.arg(
289293
Arg::new(options::MERGE)

tests/by-util/test_pr.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,3 +627,17 @@ fn test_page_header_width() {
627627
let regex = Regex::new(&pattern).unwrap();
628628
new_ucmd!().pipe_in("a").succeeds().stdout_matches(&regex);
629629
}
630+
631+
#[test]
632+
fn test_separator_options_default_values() {
633+
// -s and -S without arguments should use default values (TAB and space)
634+
// TODO: verify output matches GNU pr behavior
635+
new_ucmd!()
636+
.args(&["-t", "-2", "-s"])
637+
.pipe_in("a\nb\n")
638+
.succeeds();
639+
new_ucmd!()
640+
.args(&["-t", "-2", "-S"])
641+
.pipe_in("a\nb\n")
642+
.succeeds();
643+
}

0 commit comments

Comments
 (0)