builder: fix escaping for ENV variables.

/cc @tiborvass 

closes #8636