forked from qt-creator/qt-creator
RemoteLinux: Fix terminal opening
Enforce setting a shell to start based on whether environment variables might be set. Fixes: QTCREATORBUG-28738 Change-Id: Ic43f0057bc89410e3146bafa2b109f472e01aa3b Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -29,6 +29,10 @@ public:
|
|||||||
explicit Environment(const NameValueDictionary &dict) : m_dict(dict) {}
|
explicit Environment(const NameValueDictionary &dict) : m_dict(dict) {}
|
||||||
|
|
||||||
QString value(const QString &key) const { return m_dict.value(key); }
|
QString value(const QString &key) const { return m_dict.value(key); }
|
||||||
|
QString value_or(const QString &key, const QString &defaultValue) const
|
||||||
|
{
|
||||||
|
return m_dict.hasKey(key) ? m_dict.value(key) : defaultValue;
|
||||||
|
}
|
||||||
bool hasKey(const QString &key) const { return m_dict.hasKey(key); }
|
bool hasKey(const QString &key) const { return m_dict.hasKey(key); }
|
||||||
|
|
||||||
void set(const QString &key, const QString &value, bool enabled = true) { m_dict.set(key, value, enabled); }
|
void set(const QString &key, const QString &value, bool enabled = true) { m_dict.set(key, value, enabled); }
|
||||||
|
|||||||
@@ -1022,10 +1022,17 @@ LinuxDevice::LinuxDevice()
|
|||||||
d->m_terminals.removeOne(proc);
|
d->m_terminals.removeOne(proc);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Empty command for ssh implies the user's shell, which would be nice in general,
|
// We recreate the same way that QtcProcess uses to create the actual environment.
|
||||||
// but we can't use that if we modify environment settings, as variables without
|
const Environment finalEnv = (!env.hasChanges() && env.combineWithDeviceEnvironment())
|
||||||
// command don't work on the ssh commandline.
|
? d->getEnvironment()
|
||||||
const QString shell = env.toDictionary().size() == 0 ? QString() : QString("/bin/sh");
|
: env;
|
||||||
|
// If we will not set any environment variables, we can leave out the shell executable
|
||||||
|
// as the "ssh ..." call will automatically launch the default shell if there are
|
||||||
|
// no arguments. But if we will set environment variables, we need to explicitly
|
||||||
|
// specify the shell executable.
|
||||||
|
const QString shell = finalEnv.hasChanges() ? finalEnv.value_or("SHELL", "/bin/sh")
|
||||||
|
: QString();
|
||||||
|
|
||||||
proc->setCommand({filePath(shell), {}});
|
proc->setCommand({filePath(shell), {}});
|
||||||
proc->setTerminalMode(TerminalMode::On);
|
proc->setTerminalMode(TerminalMode::On);
|
||||||
proc->setEnvironment(env);
|
proc->setEnvironment(env);
|
||||||
|
|||||||
Reference in New Issue
Block a user