Skip to content

history -w/-a/-r/-n with HISTFILE unset silently terminates the shell (rc 2, no diagnostic, rest of the script lost) #756

Closed

Description

@caomengxuan666

Summary

history with HISTFILE unset silently terminates the shell: rc 2, no diagnostic on either stream, and the rest of the script never runs.

Repro

unset HISTFILE
history -w
echo "reached the next line"
stdout stderr rc
GNU bash reached the next line an error naming HISTFILE 0
niu / rubash (nothing) (nothing) 2

In my run the shell died at history -w and five later test groups never executed — I only noticed because the probe's output stopped mid-file. -a, -r and -n behave the same way per the sweep that found this.

Why this is the severe kind

Related, from the same sweep

Method

LF script file; niu (installed 1.4.0) vs WSL GNU bash 5.3.0; stdout and stderr captured to separate files; the truncation was confirmed by the absence of the following groups' output, not by an exit-status reading alone.

Activity

  1. added
    bug
    P1-high
    area:builtins
    area:interactive
    on Oct 17, 2026
  2. caomengxuan666 commented on Oct 17, 2026

    @caomengxuan666
    MemberAuthor

    Substantively fixed on master — closing, with one residue

    Re-measured with the regression catalogue harness (WSL GNU bash 5.3.0 oracle, both arms bounded, separate stdout/stderr, arm must reach the end of the script):

    arm unset HISTFILE; history -w; echo "reached the next line"
    installed 1.4.0 (rubash e785c3c8f610) dies at history -w: stdout empty, stderr empty, rc 2 — nothing after it runs, exactly as filed
    master (engine 30aaf207, 2026-10-17) reached the next line printed, rc 0, and one diagnostic on stderr

    So the severe half — silent shell death that swallowed the rest of the script — is gone. Worth keeping the shape in mind though, because the fix left one residue:

    GNU  : ./probe.sh: line 2: history: HISTFILE: parameter null or not set
    master: ./probe.sh: line 2: history: filename not specified
    

    Same condition, different wording, and a different prefix (history: rather than the file: line: locator form used elsewhere). That is a message-text item, not a behaviour item, so I am not keeping this issue open for it — but it is the one thing a script that greps stderr would still see.

    Closing as fixed; the wording mismatch is noted here for whoever touches that path next. The two related items from the same sweep (non-interactive sessions reading $HOME/.niubash_history while ignoring HISTFILE, and an interactive session with HISTFILE set to a scratch file loading/persisting nothing) are not re-measured here and should not be considered closed by this.

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

    P1-higharea:builtinsarea:interactivebug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions