mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
tr: require second string argument when deleting and squeezing
This commit is contained in:
parent
69ea02d9b0
commit
48c4b57c97
2 changed files with 19 additions and 0 deletions
|
@ -64,6 +64,16 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
));
|
||||
}
|
||||
|
||||
if delete_flag & squeeze_flag && sets_len < 2 {
|
||||
return Err(UUsageError::new(
|
||||
1,
|
||||
format!(
|
||||
"missing operand after {}\nTwo strings must be given when deleting and squeezing.",
|
||||
sets[0].quote()
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
if sets_len > 1 {
|
||||
let start = "extra operand";
|
||||
if delete_flag && !squeeze_flag {
|
||||
|
|
|
@ -163,6 +163,15 @@ fn test_translate_and_squeeze_multiple_lines() {
|
|||
.stdout_is("yaay\nyaay"); // spell-checker:disable-line
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_delete_and_squeeze_one_set() {
|
||||
new_ucmd!()
|
||||
.args(&["-ds", "a-z"])
|
||||
.fails()
|
||||
.stderr_contains("missing operand after 'a-z'")
|
||||
.stderr_contains("Two strings must be given when deleting and squeezing.");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_delete_and_squeeze() {
|
||||
new_ucmd!()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue