forked from qt-creator/qt-creator
Docker: fix quoting logic in withDockerExecCmd: use host OS instead of container OS
The function withDockerExecCmd previously used the OS type of the Docker container to determine the quoting style (i.e. single vs. double quotes) when composing shell commands. On Windows this led to single quotes being used in commands. Commands with single quotes cannot be executed in cmd.exe. OStype is still used in "CommandLine testType" Change-Id: I0a44bd1085df9cc4f0bb7466f056bb97cedf0b37 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
committed by
Stanislav Polukhanov
parent
ae0e846eab
commit
3af3f87ee0
@@ -776,10 +776,6 @@ Result<CommandLine> DockerDevicePrivate::withDockerExecCmd(
|
||||
else
|
||||
containerId = *result;
|
||||
|
||||
auto osAndArch = osTypeAndArch();
|
||||
if (!osAndArch)
|
||||
return make_unexpected(osAndArch.error());
|
||||
|
||||
CommandLine dockerCmd{settings().dockerBinaryPath(), {"exec"}};
|
||||
|
||||
if (interactive)
|
||||
@@ -802,12 +798,16 @@ Result<CommandLine> DockerDevicePrivate::withDockerExecCmd(
|
||||
|
||||
dockerCmd.addArg(containerId);
|
||||
|
||||
dockerCmd.addArgs({"/bin/sh", "-c"}, osAndArch->first);
|
||||
dockerCmd.addArgs({"/bin/sh", "-c"});
|
||||
|
||||
CommandLine exec("exec");
|
||||
exec.addCommandLineAsArgs(cmd, CommandLine::Raw);
|
||||
|
||||
if (withMarker) {
|
||||
auto osAndArch = osTypeAndArch();
|
||||
if (!osAndArch)
|
||||
return make_unexpected(osAndArch.error());
|
||||
|
||||
// Check the executable for existence.
|
||||
CommandLine testType({"type", {}});
|
||||
testType.addArg(cmd.executable().path(), osAndArch->first);
|
||||
@@ -821,9 +821,9 @@ Result<CommandLine> DockerDevicePrivate::withDockerExecCmd(
|
||||
|
||||
testType.addCommandLineWithAnd(echo);
|
||||
|
||||
dockerCmd.addCommandLineAsSingleArg(testType, osAndArch->first);
|
||||
dockerCmd.addCommandLineAsSingleArg(testType);
|
||||
} else {
|
||||
dockerCmd.addCommandLineAsSingleArg(exec, osAndArch->first);
|
||||
dockerCmd.addCommandLineAsSingleArg(exec);
|
||||
}
|
||||
|
||||
return dockerCmd;
|
||||
|
Reference in New Issue
Block a user