hive-bash-mcp: invoke bash via /usr/bin/env (review)
This commit is contained in:
parent
2d97401fc0
commit
ff3317eb20
1 changed files with 8 additions and 2 deletions
|
|
@ -405,7 +405,8 @@ async fn run_task(mut task: TaskFile, socket: &Path) {
|
||||||
///
|
///
|
||||||
/// Tasks run under `bash`, not `sh`: on NixOS `/bin/sh` is bash in POSIX
|
/// Tasks run under `bash`, not `sh`: on NixOS `/bin/sh` is bash in POSIX
|
||||||
/// mode, which disables bashisms (arrays, `[[ … ]]`, `local`, process
|
/// mode, which disables bashisms (arrays, `[[ … ]]`, `local`, process
|
||||||
/// substitution, …). Agents write bash, so we invoke `bash` directly.
|
/// substitution, …). Agents write bash, so we invoke `bash` (via
|
||||||
|
/// `/usr/bin/env bash`).
|
||||||
async fn exec_cmd(
|
async fn exec_cmd(
|
||||||
cmd: &str,
|
cmd: &str,
|
||||||
out_path: &Path,
|
out_path: &Path,
|
||||||
|
|
@ -415,8 +416,13 @@ async fn exec_cmd(
|
||||||
use tokio::process::Command;
|
use tokio::process::Command;
|
||||||
// SAFETY: `nice` is async-signal-safe and modifies only the calling
|
// SAFETY: `nice` is async-signal-safe and modifies only the calling
|
||||||
// process's scheduling priority before exec. No allocations, no locks.
|
// process's scheduling priority before exec. No allocations, no locks.
|
||||||
let mut cmd_builder = Command::new("bash");
|
// `/usr/bin/env bash` rather than a bare `bash`: `/usr/bin/env` is at a
|
||||||
|
// fixed absolute path (coreutils, present on NixOS), and it resolves
|
||||||
|
// `bash` via PATH — the same controlled PATH the daemon's systemd unit
|
||||||
|
// sets. Avoids hardcoding a nix store / generation path in the binary.
|
||||||
|
let mut cmd_builder = Command::new("/usr/bin/env");
|
||||||
cmd_builder
|
cmd_builder
|
||||||
|
.arg("bash")
|
||||||
.arg("-c")
|
.arg("-c")
|
||||||
.arg(cmd)
|
.arg(cmd)
|
||||||
.stdout(std::process::Stdio::piped())
|
.stdout(std::process::Stdio::piped())
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue