fix(shell): don't export DEVBOX_HIST_SET so nested shells flush history
The history-flush guard was exported, so it leaked into child processes. Any nested shell -- crucially each tmux pane (which inherits the tmux server's env) -- then saw the guard already set and skipped installing 'history -a' in PROMPT_COMMAND. Those shells only persisted history on a clean exit, so abrupt termination (docker stop, tmux kill-server, SIGKILL) silently lost their in-memory history. zoxide was less affected (its hook is installed unguarded and writes immediately). Make the guard shell-local (drop 'export') so every new interactive shell re-installs its own per-prompt flush. Add a recreate-sanity-check assertion that a nested login shell still wires up 'history -a'. Storage was never the issue: ~/.cache/bash (devbox-shell-history) and ~/.local/share/zoxide (devbox-zoxide) are both persistent named volumes.
This commit is contained in:
@@ -222,6 +222,16 @@ else
|
||||
fail "~/.bash_aliases missing"
|
||||
fi
|
||||
|
||||
# History flush must survive shell nesting. The DEVBOX_HIST_SET guard must NOT
|
||||
# be exported: if it leaks into child processes, nested shells (esp. tmux
|
||||
# panes) skip installing `history -a` and lose in-memory history on abrupt
|
||||
# termination. Assert a child login shell still wires up the per-prompt flush.
|
||||
if bash -lic 'bash -lic "case \"\$PROMPT_COMMAND\" in *\"history -a\"*) exit 0;; *) exit 1;; esac"' </dev/null >/dev/null 2>&1; then
|
||||
pass "nested shell installs 'history -a' (DEVBOX_HIST_SET not exported)"
|
||||
else
|
||||
fail "nested shell missing 'history -a' — DEVBOX_HIST_SET leaking to children?"
|
||||
fi
|
||||
|
||||
if [ -f "$HOME/.inputrc" ]; then
|
||||
pass "~/.inputrc exists"
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user