coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 'tr' strange behaviors with '-t'


From: Pádraig Brady
Subject: Re: 'tr' strange behaviors with '-t'
Date: Sun, 22 Oct 2023 16:10:43 +0100
User-agent: Mozilla Thunderbird

On 22/10/2023 00:46, Eduardo Mezêncio wrote:
Greetings,

I would like some help to understand if some behaviors of 'tr' are bugs or just 
the intended behavior.

# First case

Consider `echo aaabcc | tr -ds bc a`:
   It outputs `a` as expected, because it deletes `b` and `c` and squeezes 
`aaa` to a single `a`.

Now consider the same command including `-t`, `echo aaabcc | tr -dst bc a`:
   The result is the same, `a`, but I expected it to be `acc`, because `bc` 
would be truncated to the lenght of `a`, resulting in `b`, so `b` should be 
deleted and `a` squeezed, resulting in `acc`

# Second case

Consider `echo aaabcc | tr -c a _`:
   It outputs `aaa___` as expected

Now the same with -t, `echo aaabcc | tr -ct a _`:
   I expected it to output the same thing, because `-t` should make no 
difference in this case, but it outputs `aaabcc`, same as the input


-t is there mainly to provide compat with System V tr operation.
The full manual also states that -t is only significant with translation,
which explains the first case at least.
In the second case it depends on the order of operations,
but I expect this is compat with System V operation
(which I don't have access to to confirm at present).

cheers,
Pádraig



reply via email to

[Prev in Thread] Current Thread [Next in Thread]