coreutils icon indicating copy to clipboard operation
coreutils copied to clipboard

tr: Should not accept unaligned [:upper:]

Open BenWiederhake opened this issue 1 year ago • 2 comments

$ echo -en '123456789' | tr -t "123456789" "[:upper:]"
tr: misaligned [:upper:] and/or [:lower:] construct
[$? = 1]
$ echo -en '123456789' | cargo run tr -t "123456789" "[:upper:]"
00000000  41 42 43 44 45 46 47 48  49                       |ABCDEFGHI|
00000009
$

Note that this really checks for alignment, not just presence:

$ echo -en '123abcABC' | tr -t "1[:lower:]" "[:upper:]_"
tr: misaligned [:upper:] and/or [:lower:] construct
[$? = 1]
$ echo -en '123abcABC' | cargo run tr -t "1[:lower:]" "[:upper:]_"
A23BCDABC

(Original issue: #6133)

BenWiederhake avatar May 04 '24 16:05 BenWiederhake

Fixed by #6445.

BenWiederhake avatar Jun 10 '24 21:06 BenWiederhake

We have to reopen this issue as my PR fails to address the root problem.

this command line is fine in GNU tr but fails with uutils

tr '[:upper:][:lower:]' 'a-z[:upper:]'

Apparently GNU tr fully expands the tokens left of the upper in set2 and lower in set1 before checking.

cvonelm avatar Jun 16 '24 19:06 cvonelm

This looks like it has been resolved by #6513, hasn't it? At least currently it works, and the test added by that PR looks very similar.

BenWiederhake avatar Jul 03 '24 00:07 BenWiederhake

Yeah, this Issue is what that PR was all about

cvonelm avatar Jul 03 '24 06:07 cvonelm