Skip to content

fix: keep space-prefixed commands out of JSONL history (v2.0.3) - #11

Merged
trancong12102 merged 1 commit into
masterfrom
fix/jsonl-histcontrol
Nov 23, 2026
Merged

trancong12102 merged 1 commit into
masterfrom
fix/jsonl-histcontrol

Conversation

@trancong12102

Copy link
Copy Markdown
Contributor

Problem

With HISTCONTROL=ignoreboth and eval "$(atuin init bash)", the JSONL history recorded commands typed with a leading space (" exit", " export TOKEN=…").

bash-preexec, bundled in atuin init bash, runs __bp_adjust_histcontrol on the first prompt. That strips ignorespace and turns ignoreboth into ignoredups, so in that session HISTCONTROL is ignoredups::erasedups. From then on Bash's check_add_history, which flyline uses to decide what goes into the JSONL file, accepts space-prefixed lines.

Fix

  • New src/history/ignorespace.rs. flyline checks whether HISTCONTROL asks for ignorespace at two points: when the builtin loads, and on every flyline … command. In a normal .bashrc both happen before bash-preexec's first prompt.
  • While bash-preexec is loaded (bash_preexec_imported / __bp_imported), flyline keeps skipping space-prefixed commands, but only in the JSONL file. Bash's own history still gets the line, because bash-preexec reads it back with history 1.
  • When the JSONL file is created from Bash's in-memory history, two things change:
    • The trailing copy of the command being recorded is dropped. Before this, the first command appeared twice.
    • Space-prefixed entries are filtered out.
  • Guide note, changelog entry, and the version bump to 2.0.3.

Testing

  • cargo test --lib: 913 passed. New unit tests cover the decision logic and the seed filtering.
  • cargo fmt -- --check, cargo clippy --workspace --all-features -- -D warnings, and rustdoc with -D warnings are clean.
  • Manual check on macOS: a pty-driven interactive bash with the real .bashrc (atuin, bash-preexec, HISTCONTROL=ignoreboth:erasedups), writing to a temporary JSONL path.
    • Before the fix, echo secret3 and exit were recorded.
    • After the fix, only echo public and echo two are recorded, each once.

🤖 Generated with Claude Code

…exec

bash-preexec, which `atuin init bash` loads, rewrites HISTCONTROL on the
first prompt: it drops ignorespace and turns ignoreboth into ignoredups.
From then on Bash's check_add_history accepts lines that start with a
space, and flyline wrote them to the JSONL history.

flyline now notes whether HISTCONTROL asked for ignorespace when the
builtin loads and on each `flyline` command, and keeps skipping
space-prefixed commands while bash-preexec is loaded.

When the JSONL file is created from Bash's in-memory history, the
command being recorded is no longer written twice, and space-prefixed
entries are left out.

Release v2.0.3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@trancong12102
trancong12102 merged commit aff88c4 into master Nov 23, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant