diff --git a/README.md b/README.md index 24b6bc6..fb18161 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,8 @@ improvements. `-p=1` if this is the case. 1. Use Go regular expressions, which are perl-like. The original mk used plan9 regex, which few people know or care to learn. + 1. Regex matches are substituted into rule prerequisites with `$stem1`, + `$stem2`, etc, rather than `\1`, `\2`, etc. 1. Allow blank lines in recipes. A recipe is any indented block of text, and continues until a non-indented character or the end of the file. (Similar to blocks in Python.) diff --git a/parse.go b/parse.go index 4f3644e..da25686 100644 --- a/parse.go +++ b/parse.go @@ -308,7 +308,7 @@ func parseRecipe(p *parser, t token) parserStateFun { r.targets = append(r.targets, pattern{spat: targetstr}) if r.attributes.regex { - rpat, err := regexp.Compile(targetstr) + rpat, err := regexp.Compile("^" + targetstr + "$") if err != nil { msg := fmt.Sprintf("invalid regular expression: %q", err) p.basicErrorAtToken(msg, p.tokenbuf[k])