Skip to content

[bug] Interactive history expansion broken: !! and !$ do not reexecute/reuse (typed at prompt, no output; history file persistence itself works) #286

Closed

Description

@caomengxuan666

niubash interactive harness (tests/interactive.rs, worktree wt/interactive) findings — typed at a live prompt after a prior command: echo bang-target then !! times out with no reexecution output; echo got:$1 one-arg-style then !!/!$ reuse also nothing. Non-interactive history file persistence across sessions PASSES, alias-live and PS1 re-render PASS — the expansion-at-prompt path (history expansion during interactive read, histexp) is the broken piece. bashhist.c pre_process_comment/dbl_register... anchor: bashhist.c pre_process_line history expansion in the interactive reader. Repro harness: D:/repo/niubash-wt-interactive tests/interactive.rs (NIU_INTERACTIVE_TESTS=1 cargo test --test interactive history_bang).

Activity

  1. caomengxuan666 commented on Sep 28, 2026

    @caomengxuan666
    MemberAuthor

    lane wt8/interactive2 verification note (acceptance machine): commit b2f3d0da delivers the #286 API + tests, but the new test target script_driver_history_in_regressions is 7/8 — host_session_history_feeds_and_collects_script_expansions FAILS:

    bash: !echo: event not found
    panicked at 'expanded command output file: NotFound'
    

    Repro: cargo test --test script_driver_history_in_regressions in the lane worktree (clean env, no HIST* vars set). The host-preloaded echo seedmark entry is not found by the !echo prefix lookup in run_history_group's session.expand path. Not cherry-picked to master; the lane needs a fix pass with the full test target green before recovery (lib tests 486/486 pass; only the new target is red).

  2. caomengxuan666 commented on Sep 28, 2026

    @caomengxuan666
    MemberAuthor

    Fixed and recovered via wt10/i2re (045b649b cherry-pick of the lane's API work + 6a856dfa): the public pre_process_interactive_line seam (bashhist.c:562 pre_process_line port, integrated like the GNU interactive reader) is on master, and the acceptance-blocking S1 test turned out to be its OWN preload bug — record(..., Some(0)) meant HISTSIZE=0, and SessionHistory::record stifle-clears under it exactly like GNU (variables.c:6066 sv_histsize -> history.c:675 stifle_history frees everything past max). The test now preloads unstifled with a sealed HISTFILE/HISTSIZE environment.

    Full gates: 8/8 history regressions, 497 lib, 26 regression suite, niubash host_contract 42/42 (patch pointed at the lane tree during verification, restored after), strict -D warnings clean across all targets, WSL GNU Bash 5.3.0 byte-identical on an 8-line interactive session covering !string+redirect tail, !$, !!, failed !string/!N (event-not-found, no execution, no recording), and history recording the expanded text. Artifacts: target/issue-suites/results/i2re/

  3. added
    bug
    area:interactive
    on Oct 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:interactivebug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions