builder: fix escaping for ENV variables.

/cc @tiborvass 

closes #8636 
This should be better now.

> On Oct 17, 2014, at 2:32 PM, Erik Hollensbe <github@hollensbe.org> wrote:
> 
> OH, I thought I fixed that. One minute, thanks.
> 
> -Erik
> 
>> On Oct 17, 2014, at 2:32 PM, Alexandr Morozov <notifications@github.com <mailto:notifications@github.com>> wrote:
>> 
>> In builder/support.go:
>> 
>> >  	// this intentionally punts on more exotic interpolations like ${SOME_VAR%suffix} and lets the shell handle those directly
>> >  )
>> >  
>> >  // handle environment replacement. Used in dispatcher.
>> >  func (b *Builder) replaceEnv(str string) string {
>> >  	for _, match := range tokenEnvInterpolation.FindAllString(str, -1) {
>> > +		if strings.Index(match, "\\$") != -1 {
>> > +			idx := strings.Index(match, "\\$")
>> Why you need two same calls? Maybe you should find idx first?
>> 
>> —
>> Reply to this email directly or view it on GitHub <https://github.com/docker/docker/pull/8639/files#r19044751>.
>> 
>