mirror of
https://github.com/uutils/coreutils
synced 2024-12-14 07:12:44 +00:00
Merge pull request #5577 from cobaweel/issue-5576
Fix issue 5576 (regex matching bug in expr)
This commit is contained in:
commit
97d30bd486
2 changed files with 6 additions and 1 deletions
|
@ -498,7 +498,8 @@ fn infix_operator_and(values: &[String]) -> String {
|
|||
|
||||
fn operator_match(values: &[String]) -> Result<String, String> {
|
||||
assert!(values.len() == 2);
|
||||
let re = Regex::with_options(&values[1], RegexOptions::REGEX_OPTION_NONE, Syntax::grep())
|
||||
let re_string = format!("^{}", &values[1]);
|
||||
let re = Regex::with_options(&re_string, RegexOptions::REGEX_OPTION_NONE, Syntax::grep())
|
||||
.map_err(|err| err.description().to_string())?;
|
||||
Ok(if re.captures_len() > 0 {
|
||||
re.captures(&values[0])
|
||||
|
|
|
@ -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]
|
||||
|
|
Loading…
Reference in a new issue