hive-bash-mcp: run tasks under bash instead of sh

This commit is contained in:
damocles 2026-06-19 01:40:09 +02:00 committed by mara
commit 2d97401fc0
3 changed files with 11 additions and 7 deletions

View file

@ -151,7 +151,7 @@ fn render_bash_status(id: &str, resp: Result<DaemonResponse>, waited: bool) -> S
#[derive(Debug, Deserialize, JsonSchema)]
struct BashRunArgs {
/// Shell command to run (passed to `sh -c`).
/// Shell command to run (passed to `bash -c`).
cmd: String,
/// Timeout in seconds. Defaults to `None` (no timeout) — task runs until
/// natural exit. Pass an explicit value to kill the task after N seconds

View file

@ -1,4 +1,4 @@
//! Bash subprocess runner: spawns `sh -c <cmd>` tasks, writes status
//! Bash subprocess runner: spawns `bash -c <cmd>` tasks, writes status
//! files under `harness/bash-tasks/`, and fires hyperhive wake signals
//! on completion. Mirrors the logic previously embedded in `hive-ag3nt`.
//!
@ -400,8 +400,12 @@ async fn run_task(mut task: TaskFile, socket: &Path) {
send_wake(socket, &id, &summary, Some((out_snippet, err_snippet))).await;
}
/// Run `sh -c cmd`, streaming output to files. Returns `(exit_code, timed_out)`.
/// Run `bash -c cmd`, streaming output to files. Returns `(exit_code, timed_out)`.
/// `timeout_secs = None` means no timeout — run until natural exit.
///
/// Tasks run under `bash`, not `sh`: on NixOS `/bin/sh` is bash in POSIX
/// mode, which disables bashisms (arrays, `[[ … ]]`, `local`, process
/// substitution, …). Agents write bash, so we invoke `bash` directly.
async fn exec_cmd(
cmd: &str,
out_path: &Path,
@ -411,7 +415,7 @@ async fn exec_cmd(
use tokio::process::Command;
// SAFETY: `nice` is async-signal-safe and modifies only the calling
// process's scheduling priority before exec. No allocations, no locks.
let mut cmd_builder = Command::new("sh");
let mut cmd_builder = Command::new("bash");
cmd_builder
.arg("-c")
.arg(cmd)