1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-27 19:17:43 +00:00

expr: Handle trailing backslash error

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

View file

@ -365,6 +365,26 @@ fn test_regex() {
.stdout_only("0\n");
}
#[test]
fn test_regex_trailing_backslash() {
new_ucmd!()
.args(&["\\", ":", "\\\\"])
.succeeds()
.stdout_only("1\n");
new_ucmd!()
.args(&["\\", ":", "\\"])
.fails()
.stderr_only("expr: Trailing backslash\n");
new_ucmd!()
.args(&["abc\\", ":", "abc\\\\"])
.succeeds()
.stdout_only("4\n");
new_ucmd!()
.args(&["abc\\", ":", "abc\\"])
.fails()
.stderr_only("expr: Trailing backslash\n");
}
#[test]
fn test_substr() {
new_ucmd!()