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

Fix issue 5576 (regex matching bug in expr)

Issue 5576 reported a bug in expr, found by the fuzzer. The problem
turns out to be with the regex match operator `:`, which is defined in
POSIX and the GNU manual to match the pattern only when it occurs at
the beginning of the string, i.e., the regex has an implicit `^`
prepended to it. We hadn't been doing that.
This commit is contained in:
Coba Weel 2023-11-22 16:15:59 -08:00 committed by Daniel Hofstetter
parent fff1302bdf
commit 7efe33108a
2 changed files with 6 additions and 1 deletions

View file

@ -289,6 +289,10 @@ fn test_regex() {
.args(&["-5", ":", "-\\{0,1\\}[0-9]*$"])
.succeeds()
.stdout_only("2\n");
new_ucmd!()
.args(&["abc", ":", "bc"])
.fails()
.stdout_only("0\n");
}
#[test]