Skip to content

Commit

Permalink
fix: parse escaped parens (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret authored Nov 23, 2023
1 parent d6aa9aa commit 0b65f3b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -709,11 +709,13 @@ fn parse_word_parts(
fn first_escaped_char<'a>(
mode: ParseWordPartsMode,
) -> impl Fn(&'a str) -> ParseResult<'a, char> {
or5(
or7(
parse_special_shell_var,
parse_escaped_dollar_sign,
parse_escaped_char('`'),
parse_escaped_char('"'),
parse_escaped_char('('),
parse_escaped_char(')'),
if_true(parse_escaped_char('\''), move |_| {
mode == ParseWordPartsMode::DoubleQuotes
}),
Expand Down
9 changes: 9 additions & 0 deletions src/shell/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1265,6 +1265,15 @@ async fn glob_escapes() {
.await;
}

#[tokio::test]
async fn paren_escapes() {
TestBuilder::new()
.command(r"echo \( foo bar \)")
.assert_stdout("( foo bar )\n")
.run()
.await;
}

fn no_such_file_error_text() -> &'static str {
if cfg!(windows) {
"The system cannot find the file specified. (os error 2)"
Expand Down

0 comments on commit 0b65f3b

Please sign in to comment.