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

expr: fix substr parsing

This commit is contained in:
Tomasz Guz 2025-06-11 22:12:42 +02:00
parent 83424751c1
commit 6049bc091a
2 changed files with 16 additions and 3 deletions

View file

@ -507,6 +507,19 @@ fn test_substr() {
.stderr_only("expr: syntax error: unexpected argument 'substr'\n");
}
#[test]
fn test_substr_precedence() {
new_ucmd!()
.args(&["substr", "ab cd", "3", "1", "!=", " "])
.fails_with_code(1)
.stdout_only("0\n");
new_ucmd!()
.args(&["substr", "ab cd", "2", "1", "!=", " "])
.succeeds()
.stdout_only("1\n");
}
#[test]
fn test_invalid_substr() {
new_ucmd!()