Skip to content
Merged
5 changes: 5 additions & 0 deletions src/uu/pr/src/pr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,11 @@ fn build_options(
// --column has more priority than -column

let column_option_value = match parse_usize(matches, options::COLUMN) {
Some(Ok(0)) => {
return Err(PrError::EncounteredErrors {
msg: "invalid -column argument '0'".to_string(),
});
}
Some(res) => Some(res?),
None => start_column_option,
};
Expand Down
8 changes: 8 additions & 0 deletions tests/by-util/test_pr.rs
Comment thread
Devel08 marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -873,3 +873,11 @@ fn test_expand_tab_does_not_consume_next_argument() {
new_ucmd!().args(&["-ea", test_file_path]).succeeds();
new_ucmd!().args(&["-ea1", test_file_path]).succeeds();
}

#[test]
fn test_zero_columns() {
new_ucmd!()
.arg("--column=0")
.fails_with_code(1)
.stderr_contains("pr: invalid -column argument '0'");
Comment thread
Devel08 marked this conversation as resolved.
Outdated
}
Loading