mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
@@ -685,9 +685,9 @@ impl<'a, S: AsRef<str>> Parser<'a, S> {
|
||||
}
|
||||
}
|
||||
"substr" => {
|
||||
let string = self.parse_expression()?;
|
||||
let pos = self.parse_expression()?;
|
||||
let length = self.parse_expression()?;
|
||||
let string = self.parse_simple_expression()?;
|
||||
let pos = self.parse_simple_expression()?;
|
||||
let length = self.parse_simple_expression()?;
|
||||
AstNodeInner::Substr {
|
||||
string: Box::new(string),
|
||||
pos: Box::new(pos),
|
||||
|
||||
@@ -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!()
|
||||
|
||||
Reference in New Issue
Block a user