From ba1627ff8439a880e28ac20df8bf890b17ff18e6 Mon Sep 17 00:00:00 2001 From: Alexander Solovyov Date: Thu, 4 Sep 2014 15:15:51 +0300 Subject: [PATCH] fix percents in output: concat is bad :) --- goreplace.go | 9 +++++---- tests/main.t | 9 +++++++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/goreplace.go b/goreplace.go index 0872eb2..13836fb 100644 --- a/goreplace.go +++ b/goreplace.go @@ -17,7 +17,7 @@ import ( const ( Author = "Alexander Solovyov" - Version = "2.2" + Version = "2.3" ) var byteNewLine = []byte("\n") @@ -284,9 +284,10 @@ func (v *GRVisitor) SearchFile(fn string, content []byte) { }) v.printer.FilePrintf(fn, - "@!@y" + idxFmt + "@|" + colored + "\n", - idxFmt + colored + "\n", - info.num) + "@!@y" + idxFmt + "@|%s\n", + idxFmt + "%s\n", + info.num, + colored) } } diff --git a/tests/main.t b/tests/main.t index e6c9a2b..7d60cb0 100644 --- a/tests/main.t +++ b/tests/main.t @@ -82,3 +82,12 @@ Check that .* matches only files starting with dot: notignore 1:qwe $ cd .. + +Check that percents don't do anything bad: + + $ mkdir percent && cd percent + $ echo 'hello %username%' > one + $ gr user + one + 1:hello %username% + $ cd ..