diff --git a/libcxx/utils/ssh.py b/libcxx/utils/ssh.py --- a/libcxx/utils/ssh.py +++ b/libcxx/utils/ssh.py @@ -23,6 +23,12 @@ import tarfile import tempfile +try: + from shlex import quote as cmd_quote +except ImportError: + # for Python 2 compatibility + from pipes import quote as cmd_quote + def ssh(args, command): cmd = ['ssh', '-oBatchMode=yes'] if args.extra_ssh_args is not None: @@ -107,7 +113,7 @@ commandLine = (pathOnRemote(x) if isTestExe(x) else x for x in commandLine) remoteCommands.append('cd {}'.format(tmp)) if args.env: - remoteCommands.append('export {}'.format(' '.join(args.env))) + remoteCommands.append('export {}'.format(cmd_quote(' '.join(args.env)))) remoteCommands.append(subprocess.list2cmdline(commandLine)) # Finally, SSH to the remote host and execute all the commands.