MCPcopy Create free account
hub / github.com/KDE/konsole / checkProgram

Method checkProgram

src/session/Session.cpp:403–439  ·  view source on GitHub ↗

Upon a KPty error, there is no description on what that error was... Check to see if the given program is executable.

Source from the content-addressed store, hash-verified

401// Upon a KPty error, there is no description on what that error was...
402// Check to see if the given program is executable.
403QString 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
441void Session::terminalWarning(const QString &message)
442{

Callers

nothing calls this directly

Calls 5

isEmptyMethod · 0.80
setProgramMethod · 0.80
setArgumentsMethod · 0.80
exitCodeMethod · 0.80
QStringClass · 0.50

Tested by

no test coverage detected