← Commit list

0e09d2f85

Ron Yorston
Ron Yorston
2026-09-23
SUCCESS Duration: 236s

Subject

tr: an escaped dash doesn't indicate a range

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

coreutils/tr.c+5 -0
@@ -117,6 +117,11 @@ static unsigned expand(char *arg, char **buffer_p)
arg++;
z = arg;
ac = bb_process_escape_sequence(&z);
+ if (ac == '\\' && *z == '-') {
+ /* An escaped dash isn't a range, don't fall through */
+ buffer[pos++] = *z;
+ continue;
+ }
arg = (char *)z;
arg--;
*arg = ac;
testsuite/tr.tests+4 -0
@@ -15,6 +15,10 @@ testing "tr understands 0-9A-F" \
"tr -cd '[0-9A-F]'" \
"19AF" "" "19AFH\n"
+testing "tr does not treat [p\\-r] as a range" \
+ "tr '[p\\-r]' '+'" \
+ "o+q+s+\n" "" "opqrs-\n"
+
optional FEATURE_TR_CLASSES
testing "tr understands [:xdigit:]" \
"tr -cd '[:xdigit:]'" \