Skip to content

Commit 38a1830

Browse files
authored
fix: reserved word substrings (#263)
1 parent 1f2a18f commit 38a1830

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

crates/deno_task_shell/src/grammar.pest

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,10 @@ Stdout = ${ "|" ~ !"|" ~ !"&"}
177177
StdoutStderr = { "|&" }
178178

179179
RESERVED_WORD = _{
180-
If | Then | Else | Elif | Fi | Do | Done |
180+
(If | Then | Else | Elif | Fi | Done | Do |
181181
Case | Esac | While | Until | For |
182182
Lbrace | Rbrace | Bang | In |
183-
StdoutStderr | Stdout
183+
StdoutStderr | Stdout) ~ &(WHITESPACE | NEWLINE | EOI)
184184
}
185185

186186
// Main grammar rules

crates/tests/src/lib.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1463,6 +1463,22 @@ async fn test_set() {
14631463
.await;
14641464
}
14651465

1466+
#[tokio::test]
1467+
async fn test_reserved_substring() {
1468+
// Test that there is no panic (prefix-dev/shell#256)
1469+
TestBuilder::new()
1470+
.command(r#"fiqwertymnbvc bla"#)
1471+
.assert_exit_code(127)
1472+
.run()
1473+
.await;
1474+
1475+
TestBuilder::new()
1476+
.command(r#"forplmoknib bla"#)
1477+
.assert_exit_code(127)
1478+
.run()
1479+
.await;
1480+
}
1481+
14661482
#[cfg(test)]
14671483
fn no_such_file_error_text() -> &'static str {
14681484
if cfg!(windows) {

0 commit comments

Comments
 (0)