1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 03:27:44 +00:00

pr: fix heuristic for number-lines argument (#3109)

This commit is contained in:
Terts Diepraam 2022-02-23 23:12:05 +01:00 committed by Sylvestre Ledru
parent 75b3cbcfd9
commit bb379b5384
2 changed files with 15 additions and 1 deletions

View file

@ -448,3 +448,16 @@ fn test_with_join_lines_option() {
&valid_last_modified_template_vars(start),
);
}
#[test]
fn test_value_for_number_lines() {
// *5 is of the form [SEP[NUMBER]] so is accepted and succeeds
new_ucmd!().args(&["-n", "*5", "test.log"]).succeeds();
// a is of the form [SEP[NUMBER]] so is accepted and succeeds
new_ucmd!().args(&["-n", "a", "test.log"]).succeeds();
// foo5.txt is of not the form [SEP[NUMBER]] so is not used as value.
// Therefore, pr tries to access the file, which does not exist.
new_ucmd!().args(&["-n", "foo5.txt", "test.log"]).fails();
}