diff --git a/src/uu/sort/src/sort.rs b/src/uu/sort/src/sort.rs index 5a27a6e03..916c9915b 100644 --- a/src/uu/sort/src/sort.rs +++ b/src/uu/sort/src/sort.rs @@ -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(), diff --git a/tests/by-util/test_sort.rs b/tests/by-util/test_sort.rs index 5c753470a..fe63eb2c7 100644 --- a/tests/by-util/test_sort.rs +++ b/tests/by-util/test_sort.rs @@ -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(); +}