Skip to content

Commit

Permalink
fix reading escape strings from command line
Browse files Browse the repository at this point in the history
  • Loading branch information
piranha committed Apr 15, 2014
1 parent 60a031e commit 52adaa1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 10 additions & 1 deletion goreplace.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ import (
"os"
"path/filepath"
"regexp"
"strconv"
)

const (
Author = "Alexander Solovyov"
Version = "1.9"
Version = "1.10"
)

var byteNewLine = []byte("\n")
Expand Down Expand Up @@ -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)
}

Expand Down

0 comments on commit 52adaa1

Please sign in to comment.