fix(platform): in the Flatpak a pass's shell is bash

Flatpak sets SHELL to /bin/sh, the host's (zsh here) being no file of
the Sdk's, and claude's Bash tool runs commands with bash or zsh. In the
sandbox SHELL becomes /bin/bash unless it names a bash or zsh that is
there. Found by the sandbox checks: a pass's environment had SHELL=/bin/sh.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Jorijn van der Graaf 2026-10-31 16:09:40 +01:00
commit aaa0bb1059
Signed by: jorijnvdgraaf
GPG key ID: 2937E59CDCC1BCFB
3 changed files with 30 additions and 1 deletions

View file

@ -65,7 +65,10 @@ namespace Crafter::Review::Platform {
void Init() {
CurrentModeValue = fs::exists(PathsValue().flatpakInfo) ? Mode::Sandbox : Mode::Native;
if (CurrentModeValue == Mode::Sandbox) RestoreHostXdg();
if (CurrentModeValue == Mode::Sandbox) {
RestoreHostXdg();
RestoreShell();
}
}
Mode CurrentMode() {
@ -128,6 +131,12 @@ namespace Crafter::Review::Platform {
}
}
void RestoreShell() {
const std::string shell = GetEnv("SHELL").value_or("");
const bool usable = (shell.ends_with("/bash") || shell.ends_with("/zsh")) && access(shell.c_str(), X_OK) == 0;
if (!usable && access("/bin/bash", X_OK) == 0) setenv("SHELL", "/bin/bash", 1);
}
fs::path SelfExe() {
std::error_code error;
const fs::path exe = fs::read_symlink("/proc/self/exe", error);