From 874a9304cf22255420415d0b08b2786328b173d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Teemu=20P=C3=A4tsi?= Date: Tue, 27 May 2025 04:02:01 +0300 Subject: [PATCH] expr: Remove nonexistent error `UnmatchedClosingBrace` The closing brace without related opening brace is handled literally --- src/uu/expr/src/expr.rs | 2 -- src/uu/expr/src/syntax_tree.rs | 10 +--------- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/src/uu/expr/src/expr.rs b/src/uu/expr/src/expr.rs index fa165f9f3..70f4e62d2 100644 --- a/src/uu/expr/src/expr.rs +++ b/src/uu/expr/src/expr.rs @@ -46,8 +46,6 @@ pub enum ExprError { UnmatchedClosingParenthesis, #[error("Unmatched \\{{")] UnmatchedOpeningBrace, - #[error("Unmatched ) or \\}}")] - UnmatchedClosingBrace, #[error("Invalid content of \\{{\\}}")] InvalidBracketContent, #[error("Trailing backslash")] diff --git a/src/uu/expr/src/syntax_tree.rs b/src/uu/expr/src/syntax_tree.rs index fa9d71a21..e315535f6 100644 --- a/src/uu/expr/src/syntax_tree.rs +++ b/src/uu/expr/src/syntax_tree.rs @@ -365,9 +365,7 @@ fn check_posix_regex_errors(pattern: &str) -> ExprResult<()> { } (true, '}') => { if !is_brace_ignored { - escaped_braces = escaped_braces - .saturating_sub(1) - .ok_or(ExprError::UnmatchedClosingBrace)?; + escaped_braces = escaped_braces.saturating_sub(1); } } _ => {} @@ -1007,12 +1005,6 @@ mod test { Err(ExprError::UnmatchedClosingParenthesis) ); - assert_eq!( - check_posix_regex_errors(r"abc\}"), - Err(ExprError::UnmatchedClosingBrace) - ); - } - #[test] fn check_regex_empty_repeating_pattern() { assert_eq!(