1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

tr: implement translate and squeeze (-s) mode

Add translate and squeeze mode to the `tr` program. For example:

    $ printf xx | tr -s x y
    y

Fixes #2141.
This commit is contained in:
Jeffrey Finkelstein 2021-04-29 23:13:20 -04:00
parent 247de489f5
commit 0f3bc23739
2 changed files with 70 additions and 2 deletions

View file

@ -63,6 +63,24 @@ fn test_squeeze_complement() {
.stdout_is("aaBcDcc");
}
#[test]
fn test_translate_and_squeeze() {
new_ucmd!()
.args(&["-s", "x", "y"])
.pipe_in("xx")
.run()
.stdout_is("y");
}
#[test]
fn test_translate_and_squeeze_multiple_lines() {
new_ucmd!()
.args(&["-s", "x", "y"])
.pipe_in("xxaax\nxaaxx")
.run()
.stdout_is("yaay\nyaay");
}
#[test]
fn test_delete_and_squeeze() {
new_ucmd!()