Skip to content

Commit ab5cf74

Browse files
committed
expr: Simplify parsing special cases for $ in regex
1 parent 2a862bc commit ab5cf74

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

src/uu/expr/src/syntax_tree.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -185,14 +185,8 @@ impl StringOp {
185185
| ('\\', false) => re_string.push(curr),
186186
_ => re_string.push_str(r"\^"),
187187
},
188-
'$' => {
189-
if is_end_of_expression(&pattern_chars) {
190-
re_string.push(curr);
191-
} else if !curr_is_escaped {
192-
re_string.push_str(r"\$");
193-
} else {
194-
re_string.push(curr);
195-
}
188+
'$' if !curr_is_escaped && !is_end_of_expression(&pattern_chars) => {
189+
re_string.push_str(r"\$");
196190
}
197191
'\\' if !curr_is_escaped && pattern_chars.peek().is_none() => {
198192
return Err(ExprError::TrailingBackslash);

0 commit comments

Comments
 (0)