Skip to content

Commit

Permalink
interp: support multiline strings when pattern matching in [[
Browse files Browse the repository at this point in the history
  • Loading branch information
ihar-orca authored and mvdan committed May 23, 2022
1 parent 0aaaab3 commit cbb1e13
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions interp/interp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1551,6 +1551,10 @@ var runTests = []runTest{
"[[ -L a ]] && echo x; ln -s b a; [[ -L a ]] && echo y;",
"y\n",
},
{
"[[ \"multiline\ntext\" == *text* ]] && echo x; [[ \"multiline\ntext\" == *multiline* ]] && echo y",
"x\ny\n",
},
{
"mkdir a; cd a; test -f b && echo x; >b; test -f b && echo y",
"y\n",
Expand Down
2 changes: 1 addition & 1 deletion interp/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ func match(pat, name string) bool {
if err != nil {
return false
}
rx := regexp.MustCompile("^" + expr + "$")
rx := regexp.MustCompile("(?m)^" + expr + "$")
return rx.MatchString(name)
}

Expand Down

0 comments on commit cbb1e13

Please sign in to comment.