diff --git a/src/uu/cut/src/cut.rs b/src/uu/cut/src/cut.rs index 05e8bc6e4..0555be14f 100644 --- a/src/uu/cut/src/cut.rs +++ b/src/uu/cut/src/cut.rs @@ -426,7 +426,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { delim = ""; } if delim.chars().count() > 1 { - Err("invalid input: The '--delimiter' ('-d') option expects empty or 1 character long, but was provided a value 2 characters or longer".into()) + Err("the delimiter must be a single character".into()) } else { let delim = if delim.is_empty() { "\0".to_owned() diff --git a/tests/by-util/test_cut.rs b/tests/by-util/test_cut.rs index 184e413a8..112dc0fd3 100644 --- a/tests/by-util/test_cut.rs +++ b/tests/by-util/test_cut.rs @@ -126,7 +126,7 @@ fn test_too_large() { } #[test] -fn test_specify_delimiter() { +fn test_delimiter() { for param in ["-d", "--delimiter", "--del"] { new_ucmd!() .args(&[param, ":", "-f", COMPLEX_SEQUENCE.sequence, INPUT]) @@ -135,6 +135,15 @@ fn test_specify_delimiter() { } } +#[test] +fn test_delimiter_with_more_than_one_char() { + new_ucmd!() + .args(&["-d", "ab", "-f1"]) + .fails() + .stderr_contains("cut: the delimiter must be a single character") + .no_stdout(); +} + #[test] fn test_output_delimiter() { // we use -d here to ensure output delimiter