Linuxdevice: Remove profile sourcing when fetching environment

SshProcessInterfacePrivate::fullLocalCommandLine() will already add the
sourcing itself. No need to add it manually again.

Fixes QNX devices mostly.

Change-Id: I552a432f5adf367318444e6c6dff815fed67d9a7
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Marcus Tillmanns
2025-04-11 15:33:58 +02:00
committed by hjk
parent ddb8adc531
commit 0503f267e2

View File

@@ -378,21 +378,17 @@ Environment LinuxDevicePrivate::getEnvironment()
if (m_disconnected()) if (m_disconnected())
return {}; return {};
const bool sourceProfile = q->extraData(Constants::SourceProfile).toBool();
CommandLine cmd;
if (sourceProfile) {
cmd.setExecutable(q->filePath("sh"));
cmd.addArgs({"-c", ". /etc/profile ; . ~/.profile ; env"});
} else {
cmd.setExecutable(q->filePath("env"));
}
Process getEnvProc; Process getEnvProc;
getEnvProc.setCommand(cmd); getEnvProc.setCommand({q->filePath("env"), {}});
using namespace std::chrono; using namespace std::chrono;
getEnvProc.runBlocking(5s); getEnvProc.runBlocking(5s);
if (getEnvProc.result() != ProcessResult::FinishedWithSuccess) {
qCWarning(linuxDeviceLog) << "Failed to get environment variables from device:"
<< getEnvProc.exitMessage() << getEnvProc.allOutput();
return {};
}
const QString remoteOutput = getEnvProc.cleanedStdOut(); const QString remoteOutput = getEnvProc.cleanedStdOut();
m_environmentCache = Environment(remoteOutput.split('\n', Qt::SkipEmptyParts), q->osType()); m_environmentCache = Environment(remoteOutput.split('\n', Qt::SkipEmptyParts), q->osType());
return m_environmentCache.value(); return m_environmentCache.value();