Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions brush-parser/src/word.rs
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,8 @@ peg::parser! {
rule unquoted_literal_text_piece<T>(stop_condition: rule<T>, in_command: bool) =
is_true(in_command) extglob_pattern() /
is_true(in_command) subshell_command() /
!stop_condition() !normal_escape_sequence() !enabled_tilde_expr_after_colon() [^'\'' | '\"' | '$' | '`'] {}
is_true(in_command) !stop_condition() !normal_escape_sequence() !enabled_tilde_expr_after_colon() [^'\'' | '\"' | '$' | '`' | '#'] {} /
is_false(in_command) !stop_condition() !normal_escape_sequence() !enabled_tilde_expr_after_colon() [^'\'' | '\"' | '$' | '`'] {}

rule enabled_tilde_expr_after_colon() -> WordPiece =
tilde_exprs_after_colon_enabled() last_char_is_colon() piece:tilde_expression_piece() { piece }
Expand All @@ -821,6 +822,7 @@ peg::parser! {
}}

rule is_true(value: bool) = &[_] {? if value { Ok(()) } else { Err("not true") } }
rule is_false(value: bool) = &[_] {? if !value { Ok(()) } else { Err("not false") } }

rule extglob_pattern() =
("@" / "!" / "?" / "+" / "*") "(" extglob_body_piece()* ")" {}
Expand Down Expand Up @@ -1033,7 +1035,8 @@ peg::parser! {

pub(crate) rule command_piece() -> () =
word_piece(<[')']>, true /*in_command*/) {} /
([' ' | '\t'])+ {}
([' ' | '\t' | '\n'])+ {} /
"#" [^'\n']* {}

rule backquoted_command() -> String =
chars:(backquoted_char()*) { chars.into_iter().collect() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,3 +182,16 @@ cases:

$($(:))
echo "exit code: $?"

- name: "Comment in command substitution without newline fails"
known_failure: true
stdin: |
x=$(echo # must fail)

- name: "Comment in command substitution with newline"
stdin: |
x=$(
echo "a" # comment with "quote
echo "b"
)
echo "$x"
Loading