'Escape special bash characters in command to wrap in shell
In order to set the current working path inside a docker container, we
need to wrap the command in a shell call manually. Some characters will
be interpreted as shell characters without escaping, such as: ``pip
install requests<0.8``. This escapes a good majority of those
characters.'

def get_wrapped_command(self):

    bash_escape_re = re.compile('([\\t\\    \\!\\"\\#\\$\\&\\\'\\(\\)\\*\\:\\;\\<\\>\\?\\@\\[\\\\\\]\\^\\`\\{\\|\\}\\~])')
    prefix = ''
    if self.bin_path:
        prefix += 'PATH={0}:$PATH    '.format(self.bin_path)
    return "/bin/sh    -c    'cd    {cwd}    &&    {prefix}{cmd}'".format(cwd=self.cwd, prefix=prefix, cmd='    '.join([bash_escape_re.sub('\\\\\\1', part) for part in self.command]))
