fix(bash): re-exported env vars referenced by snapshotted shell functions

generateSnapshotScript captured the user's shell functions via declare -f /
typeset -f and dropped everything except PATH on the export floor. mise
activate installs a mise() function whose body expands $__MISE_EXE; the
replay shell then ran `command "" "$@"` and died with
`command: command not found:` (exit 127). The same shape breaks asdf
shims, direnv-style helpers, and any other activation idiom that pairs a
shell function with a sidecar env var.

The snapshot script now scans captured function bodies for $VAR /
${VAR…} references and re-emits `export NAME='value'` for each name
that is currently set and not on a shell-internal denylist (PATH, HOME,
BASH_*, LC_*, …). getShellConfigFile also honours env.HOME so callers
(and tests) can target a sandboxed home — os.homedir() is cached by Bun
and ignores later process.env.HOME mutations.

Fixes #3470
This commit is contained in:
roboomp
2026-06-25 15:10:59 +00:00
parent 451af61280
commit 77265de55e
5 changed files with 228 additions and 19 deletions
+5
View File
@@ -28,6 +28,11 @@ declare module "*.lark" {
export default content;
}
declare module "*.sh" {
const content: string;
export default content;
}
declare module "*.bdf" {
const content: string;
export default content;