You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Grouped readers / PROMPT_COMMAND shadow a host HistoryProvider and wipe interactive history (niubash#508 part B) #1007
Host-visible bug reported in unixwin/niubash#508 (closed after its arithmetic half shipped via rubash#1006; this is the remaining history half).
Symptom
Interactive niu REPL (oh-my-bash/omb defines alias 1='cd -1'):
typing history 1, or any line containing ;, empties history/fc for the rest of the session.
Root cause
niubash's interactive reader routes a line through the engine's grouped driver (run_script_with_history_at_line_offset) when the token stream contains ;/operators/keywords or a token matching an alias name. The driver unconditionally installed a fresh empty SessionHistory via set_session_history. job_builtins::execute_history and fc resolve the shell's ONE list (builtins/history.def) with session-over-provider precedence, so the installed scratch permanently shadowed the host's reedline-backed HistoryProvider — an installed provider IS the_history_list in this embedding.
The PROMPT_COMMAND runner's empty-session arm (run_prompt_command_textNone branch) and prepare_interactive_history had the same unconditional-install shape.
Fix
One invariant: an installed HistoryProvider is never shadowed by an engine scratch session.
run_script_grouped_at_line_offset gains an install_session flag keyed on executor.has_history_provider(); the scratch still backs the batch's expansion/record mechanics without becoming the shell's list.
New run_script_with_fresh_history_in_tracked for the PROMPT_COMMAND empty-session arm, same guard.
prepare_interactive_history skips session creation when a provider is installed.
New pub(crate) accessor Executor::has_history_provider.
Without a provider the scratch still installs — GNU's fresh per-shell history list (bashhist.c pre_process_line / shell.c reader loop). In GNU there is only ever one list; this is an embedding-contract fix, not a GNU semantic divergence.
Regressions
tests/script_driver_history_in_regressions.rs: provider list survives a grouped batch (history 1 inside the batch still lists provider entries; a second batch still sees them), PROMPT_COMMAND no longer shadows the provider, and the providerless arms still install fresh sessions.
Host-side end-to-end verified against niubash@23a1278: echo a; echo b, alias 1='cd -1' + history 1 (prints the provider's last entry), then plain history — provider list intact. No niubash-side change needed; the existing call site already routes through the fixed driver.
Activity
Merge pull request #1008 from unixwin/fix/508-history-reset