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

expr: Handle $ at the beginning of the regex pattern

This commit is contained in:
Teemu Pätsi 2025-05-24 01:28:53 +03:00
parent 4555e6fe48
commit b0390fe36e
No known key found for this signature in database
GPG key ID: 5494F73B045AB692
2 changed files with 40 additions and 15 deletions

View file

@ -318,6 +318,14 @@ fn test_regex() {
.args(&["a$c", ":", "a$\\c"])
.succeeds()
.stdout_only("3\n");
new_ucmd!()
.args(&["$a", ":", "$a"])
.succeeds()
.stdout_only("2\n");
new_ucmd!()
.args(&["a", ":", "a$\\|b"])
.succeeds()
.stdout_only("1\n");
new_ucmd!()
.args(&["^^^^^^^^^", ":", "^^^"])
.succeeds()
@ -363,6 +371,14 @@ fn test_regex() {
.args(&["abc", ":", "ab[^c]"])
.fails()
.stdout_only("0\n");
new_ucmd!()
.args(&["$", ":", "$"])
.fails()
.stdout_only("0\n");
new_ucmd!()
.args(&["a$", ":", "a$\\|b"])
.fails()
.stdout_only("0\n");
}
#[test]