From 674aad728e3c92e6840702d6da7fc5142054dc41 Mon Sep 17 00:00:00 2001 From: hjk Date: Fri, 16 Dec 2022 11:02:09 +0100 Subject: [PATCH] RemoteLinux: Hard-code /bin/sh for use in Open Terminal ... when changes to the environment are requested. Ideally, that should be the user's chosen shell on the device, but ssh does not support the case of specifying shell variables without also giving an executable. Short of playing tricks with /etc/passwd, getent, or env, use /bin/sh which is guaranteed to exist. Change-Id: I8d4b87f2a94eb9614d85dcacebd539ac645dc33d Reviewed-by: Christian Kandeler --- src/plugins/remotelinux/linuxdevice.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/plugins/remotelinux/linuxdevice.cpp b/src/plugins/remotelinux/linuxdevice.cpp index e2948b6f192..e95e0e753e2 100644 --- a/src/plugins/remotelinux/linuxdevice.cpp +++ b/src/plugins/remotelinux/linuxdevice.cpp @@ -976,7 +976,11 @@ LinuxDevice::LinuxDevice() d->m_terminals.removeOne(proc); }); - proc->setCommand({filePath({}), {}}); + // Empty command for ssh implies the user's shell, which would be nice in general, + // but we can't use that if we modify environment settings, as variables without + // command don't work on the ssh commandline. + const QString shell = env.toDictionary().size() == 0 ? QString() : QString("/bin/sh"); + proc->setCommand({filePath(shell), {}}); proc->setTerminalMode(TerminalMode::On); proc->setEnvironment(env); proc->setWorkingDirectory(workingDir);