Commit 5871a53c authored by Adriaan de Groot's avatar Adriaan de Groot 💬
Browse files

Allow sessions with /bin/sh

The existing code scans through `programs` to find an acceptable
shell to start; `_program` is the shell that is configured for
the session (line 456). The first shell to be found from that
list, is assigned to `exec` and we'll run that shell.

If the shell found wasn't the one configured (e.g. one of the
other ones from the list) then a warning is printed, but we carry on.
**However**, if the shell found is the **last** one in the list
(i.e. `/bin/sh`) then a warning is printed and the shell does
not start.

If the configured shell is `/bin/sh` this obviously breaks down:
it is found (as the first one in the list!) but still equals the
last one; the warning is printed and nothing runs.

It is unclear **why** `/bin/sh` is not allowed as a shell:
it exists, it's an executable, and it's an interactive shell.

Curiously, configuring the shell as `sh` for the session runs
`/bin/sh` in the end, but just tricks the logic here:
 - `checkProgram("sh")` returns `sh` as string,
 - so the comparison against `/bin/sh` fails,
 - and we can run `sh` .. which is `/bin/sh`.

There's no good reason to forbid `/bin/sh`, so change the check to
**only** fail if no shell was found at all (`exec` stayed empty)
or if the found shell behaves weirdly (is not equal to itself).
parent 1cda384e
...@@ -472,15 +472,19 @@ void Session::run() ...@@ -472,15 +472,19 @@ void Session::run()
} }
} }
// if a program was specified via setProgram(), but it couldn't be found, print a warning // if nothing could be found (not even the fallbacks), print a warning and do not run
if (exec != checkProgram(_program)) { if (exec.isEmpty()) {
terminalWarning(i18n("Could not find '%1', starting '%2' instead. Please check your profile settings.", _program, exec));
// if none of the choices are available, print a warning
} else if (programs.last() == checkProgram(exec)) {
terminalWarning(i18n("Could not find an interactive shell to start.")); terminalWarning(i18n("Could not find an interactive shell to start."));
return; return;
} }
// if a program was specified via setProgram(), but it couldn't be found (but a fallback was), print a warning
if (exec != checkProgram(_program)) {
terminalWarning(i18n("Could not find '%1', starting '%2' instead. Please check your profile settings.", _program, exec));
} else if ( exec != checkProgram(exec)) {
terminalWarning(i18n("Could not find '%1', starting '%2' instead. Please check your profile settings.", exec, checkProgram(exec)));
}
// if no arguments are specified, fall back to program name // if no arguments are specified, fall back to program name
QStringList arguments = _arguments.join(QLatin1Char(' ')).isEmpty() ? QStringList arguments = _arguments.join(QLatin1Char(' ')).isEmpty() ?
QStringList() << exec : QStringList() << exec :
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment