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

tr: don't truncate when not translating

An additional issue was found while reviewing #6340, check [this thread][1]. A summary is:

- `tr` ignores the `-t`/`--truncate-set1` flag when not translating
- Not translating is defined as `-d` was passed, or one set was passed.

[1]: https://github.com/uutils/coreutils/pull/6340#discussion_r1590007053
This commit is contained in:
Jalil David Salamé Messina 2024-05-04 15:26:47 +02:00 committed by Ben Wiederhake
parent 3c47f27698
commit ff1a03c284
2 changed files with 36 additions and 2 deletions

View file

@ -2,7 +2,7 @@
//
// For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code.
// spell-checker:ignore aabbaa aabbcc aabc abbb abbbcddd abcc abcdefabcdef abcdefghijk abcdefghijklmn abcdefghijklmnop ABCDEFGHIJKLMNOPQRS abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFZZ abcxyz ABCXYZ abcxyzabcxyz ABCXYZABCXYZ acbdef alnum amzamz AMZXAMZ bbbd cclass cefgm cntrl compl dabcdef dncase Gzabcdefg PQRST upcase wxyzz xdigit XXXYYY xycde xyyye xyyz xyzzzzxyzzzz ZABCDEF Zamz Cdefghijkl Cdefghijklmn
// spell-checker:ignore aabbaa aabbcc aabc abbb abbbcddd abcc abcdefabcdef abcdefghijk abcdefghijklmn abcdefghijklmnop ABCDEFGHIJKLMNOPQRS abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFZZ abcxyz ABCXYZ abcxyzabcxyz ABCXYZABCXYZ acbdef alnum amzamz AMZXAMZ bbbd cclass cefgm cntrl compl dabcdef dncase Gzabcdefg PQRST upcase wxyzz xdigit XXXYYY xycde xyyye xyyz xyzzzzxyzzzz ZABCDEF Zamz Cdefghijkl Cdefghijklmn asdfqqwweerr qwerr asdfqwer qwer aassddffqwer asdfqwer
use crate::common::util::TestScenario;
#[test]
@ -1334,3 +1334,33 @@ fn check_regression_issue_6163_match() {
.no_stderr()
.stdout_only("Z\n");
}
#[test]
fn check_ignore_truncate_when_deleting_and_squeezing() {
new_ucmd!()
.args(&["-dts", "asdf", "qwe"])
.pipe_in("asdfqqwweerr\n")
.succeeds()
.no_stderr()
.stdout_only("qwerr\n");
}
#[test]
fn check_ignore_truncate_when_deleting() {
new_ucmd!()
.args(&["-dt", "asdf"])
.pipe_in("asdfqwer\n")
.succeeds()
.no_stderr()
.stdout_only("qwer\n");
}
#[test]
fn check_ignore_truncate_when_squeezing() {
new_ucmd!()
.args(&["-ts", "asdf"])
.pipe_in("aassddffqwer\n")
.succeeds()
.no_stderr()
.stdout_only("asdfqwer\n");
}