diff --git a/README.md b/README.md index 324cf45..6e5f6af 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,10 @@ supported as replacement, no regexp submatch support yet (planned, though). ## Changelog + - 1.10 + - Fix reading escapes (like `\n`) from command line + - 1.9 + - Treat `$1` in replacement strings as groups - 1.8 - Fix `.*` handling in `.gitignore` (it actually matched `.` and ignored absolutely everything) diff --git a/goreplace.go b/goreplace.go index 52fff7e..a7884e6 100644 --- a/goreplace.go +++ b/goreplace.go @@ -11,11 +11,12 @@ import ( "os" "path/filepath" "regexp" + "strconv" ) const ( Author = "Alexander Solovyov" - Version = "1.9" + Version = "1.10" ) var byteNewLine = []byte("\n") @@ -92,6 +93,14 @@ func main() { errhandle(fmt.Errorf("Your pattern matches empty string"), true) } + if opts.Replace != nil { + s, err := strconv.Unquote(`"` + *opts.Replace + `"`) + if err != nil { + errhandle(err, true) + } + *opts.Replace = s + } + searchFiles(pattern, ignoreFileMatcher, acceptedFileMatcher) }