Upon a KPty error, there is no description on what that error was... Check to see if the given program is executable.
| 401 | // Upon a KPty error, there is no description on what that error was... |
| 402 | // Check to see if the given program is executable. |
| 403 | QString Session::checkProgram(const QString &program) |
| 404 | { |
| 405 | QString exec = program; |
| 406 | |
| 407 | if (exec.isEmpty()) { |
| 408 | return QString(); |
| 409 | } |
| 410 | |
| 411 | #ifndef Q_OS_WIN |
| 412 | if (KSandbox::isFlatpak()) { |
| 413 | QProcess proc; |
| 414 | // run "test -x exec" on the host to see if the shell is executable |
| 415 | proc.setProgram(QStringLiteral("test")); |
| 416 | proc.setArguments(QStringList{QStringLiteral("-x"), exec}); |
| 417 | KSandbox::startHostProcess(proc, QProcess::ReadOnly); |
| 418 | if (proc.waitForStarted() && proc.waitForFinished(-1)) { |
| 419 | return proc.exitCode() == 0 ? exec : QString(); |
| 420 | } |
| 421 | return {}; |
| 422 | } |
| 423 | #endif // Q_OS_WIN |
| 424 | |
| 425 | QFileInfo info(exec); |
| 426 | if (info.isAbsolute() && info.exists() && info.isExecutable()) { |
| 427 | return exec; |
| 428 | } |
| 429 | |
| 430 | exec = KIO::DesktopExecParser::executablePath(exec); |
| 431 | exec = KShell::tildeExpand(exec); |
| 432 | const QString pexec = QStandardPaths::findExecutable(exec); |
| 433 | if (pexec.isEmpty()) { |
| 434 | qCritical() << i18n("Could not find binary: ") << exec; |
| 435 | return QString(); |
| 436 | } |
| 437 | |
| 438 | return exec; |
| 439 | } |
| 440 | |
| 441 | void Session::terminalWarning(const QString &message) |
| 442 | { |
nothing calls this directly
no test coverage detected