mirror of
https://invent.kde.org/system/dolphin
synced 2024-09-12 12:54:29 +00:00
terminal: Clear line using escapes instead of SIGINT
Sending SIGINT can be destructive, for example if we interrupt the loading of the shell init files (e.g. .bashrc) and clobber history preservation settings. Follow the example of Kate and send a Ctrl-E Ctrl-U to clear the prompt instead. BUG: 279614 Signed-off-by: John Brooks <john@fastquake.com>
This commit is contained in:
parent
2f171f570e
commit
3656da18b0
|
@ -239,18 +239,10 @@ void TerminalPanel::sendCdToTerminal(const QString& dir, HistoryPolicy addToHist
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef Q_OS_WIN
|
// Send prior Ctrl-E, Ctrl-U to ensure the line is empty. This is
|
||||||
if (!m_clearTerminal) {
|
// mandatory, otherwise sending a 'cd x\n' to a prompt with 'rm -rf *'
|
||||||
// The TerminalV2 interface does not provide a way to delete the
|
// would result in data loss.
|
||||||
// current line before sending a new input. This is mandatory,
|
m_terminal->sendInput(QStringLiteral("\x05\x15"));
|
||||||
// otherwise sending a 'cd x' to a existing 'rm -rf *' might
|
|
||||||
// result in data loss. As workaround SIGINT is sent.
|
|
||||||
const int processId = m_terminal->terminalProcessId();
|
|
||||||
if (processId > 0) {
|
|
||||||
kill(processId, SIGINT);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// We want to ignore the currentDirectoryChanged(QString) signal, which we will receive after
|
// We want to ignore the currentDirectoryChanged(QString) signal, which we will receive after
|
||||||
// the directory change, because this directory change is not caused by a "cd" command that the
|
// the directory change, because this directory change is not caused by a "cd" command that the
|
||||||
|
|
Loading…
Reference in a new issue