diff --git a/src/uu/df/src/df.rs b/src/uu/df/src/df.rs index a7520117d..3de605364 100644 --- a/src/uu/df/src/df.rs +++ b/src/uu/df/src/df.rs @@ -443,14 +443,14 @@ pub fn uu_app<'a>() -> Command<'a> { Arg::new(OPT_HUMAN_READABLE_BINARY) .short('h') .long("human-readable") - .conflicts_with(OPT_HUMAN_READABLE_DECIMAL) + .overrides_with(OPT_HUMAN_READABLE_DECIMAL) .help("print sizes in human readable format (e.g., 1K 234M 2G)"), ) .arg( Arg::new(OPT_HUMAN_READABLE_DECIMAL) .short('H') .long("si") - .conflicts_with(OPT_HUMAN_READABLE_BINARY) + .overrides_with(OPT_HUMAN_READABLE_DECIMAL) .help("likewise, but use powers of 1000 not 1024"), ) .arg( diff --git a/tests/by-util/test_df.rs b/tests/by-util/test_df.rs index d91f1ac36..a76cf5fd7 100644 --- a/tests/by-util/test_df.rs +++ b/tests/by-util/test_df.rs @@ -26,6 +26,12 @@ fn test_df_compatible_si() { new_ucmd!().arg("-aH").succeeds(); } +#[test] +fn test_df_overriding() { + new_ucmd!().arg("-hH").succeeds(); + new_ucmd!().arg("-Hh").succeeds(); +} + #[test] fn test_df_output() { let expected = if cfg!(target_os = "macos") { @@ -42,6 +48,22 @@ fn test_df_output() { assert_eq!(actual, expected); } +#[test] +fn test_df_output_overridden() { + let expected = if cfg!(target_os = "macos") { + "Filesystem Size Used Available Capacity Use% Mounted on " + } else { + "Filesystem Size Used Available Use% Mounted on " + }; + let output = new_ucmd!() + .arg("-hH") + .arg("--total") + .succeeds() + .stdout_move_str(); + let actual = output.lines().take(1).collect::>()[0]; + assert_eq!(actual, expected); +} + #[test] fn test_total_option_with_single_dash() { // These should fail because `-total` should have two dashes,