┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/panels
diff options
context:
space:
mode:
authorJohn Brooks <[email protected]>2022-09-03 18:22:15 -0400
committerMéven Car <[email protected]>2022-10-02 07:14:23 +0000
commit3656da18b094299c1f58245052af0f429857a6e4 (patch)
tree54d74c1d5e0604bc695b9786b8dd41c1b382c1c1 /src/panels
parent2f171f570e59cfd8888f070aa372b02d331c9462 (diff)
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 <[email protected]>
Diffstat (limited to 'src/panels')
-rw-r--r--src/panels/terminal/terminalpanel.cpp16
1 files changed, 4 insertions, 12 deletions
diff --git a/src/panels/terminal/terminalpanel.cpp b/src/panels/terminal/terminalpanel.cpp
index 86d3fd555..22f840f5c 100644
--- a/src/panels/terminal/terminalpanel.cpp
+++ b/src/panels/terminal/terminalpanel.cpp
@@ -239,18 +239,10 @@ void TerminalPanel::sendCdToTerminal(const QString& dir, HistoryPolicy addToHist
return;
}
-#ifndef Q_OS_WIN
- if (!m_clearTerminal) {
- // The TerminalV2 interface does not provide a way to delete the
- // current line before sending a new input. This is mandatory,
- // 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
+ // Send prior Ctrl-E, Ctrl-U to ensure the line is empty. This is
+ // mandatory, otherwise sending a 'cd x\n' to a prompt with 'rm -rf *'
+ // would result in data loss.
+ m_terminal->sendInput(QStringLiteral("\x05\x15"));
// 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