Skip to content

Commit

Permalink
Add "+=" operator to bash syntax parser
Browse files Browse the repository at this point in the history
  • Loading branch information
wedaly committed Mar 19, 2024
1 parent 56eece1 commit dacb2cd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion syntax/languages/bash.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func BashParseFunc() parser.Func {

parseOperator := consumeLongestMatchingOption([]string{
"$", "!", "<", ">", "<<", ">>",
"|", "&&", "||", "=", "&>", ">&", "&>>",
"|", "&&", "||", "=", "+=", "&>", ">&", "&>>",
}).Map(recognizeToken(parser.TokenRoleOperator))

parseStartConditional := matchState(
Expand Down
8 changes: 8 additions & 0 deletions syntax/languages/bash_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,14 @@ heredoc text
{Role: parser.TokenRoleOperator, Text: `=`},
},
},
{
name: "append operator",
text: `GLOB+="foo"`,
expected: []TokenWithText{
{Role: parser.TokenRoleOperator, Text: `+=`},
{Role: parser.TokenRoleString, Text: `"foo"`},
},
},
{
name: "conditional with regex start of line",
text: `[[ $line =~ ^"initial string" ]]`,
Expand Down

0 comments on commit dacb2cd

Please sign in to comment.