Skip to content

Commit

Permalink
Merge pull request #4132 from tertsdiepraam/sort-accept-sort-mode-mul…
Browse files Browse the repository at this point in the history
…tiple-times

`sort`: allow a sort mode to appear multiple times
  • Loading branch information
sylvestre authored Nov 17, 2022
2 parents 54b4b56 + 03c40b2 commit 435ef5d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/uu/sort/src/sort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ impl KeySettings {
}

fn set_sort_mode(&mut self, mode: SortMode) -> Result<(), String> {
if self.mode != SortMode::Default {
if self.mode != SortMode::Default && self.mode != mode {
return Err(format!(
"options '-{}{}' are incompatible",
self.mode.get_short_name().unwrap(),
Expand Down
5 changes: 5 additions & 0 deletions tests/by-util/test_sort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1156,3 +1156,8 @@ fn test_tmp_files_deleted_on_sigint() {
// `sort` should have deleted the temporary directory again.
assert!(read_dir(at.plus("tmp_dir")).unwrap().next().is_none());
}

#[test]
fn test_same_sort_mode_twice() {
new_ucmd!().args(&["-k", "2n,2n", "empty.txt"]).succeeds();
}

0 comments on commit 435ef5d

Please sign in to comment.