Two interactive Bash sessions are open with normal settings.
A command just run in one session is not yet present when the other rereads ~/.bash_history.
Which general explanation is appropriate?
Each Bash keeps a session history list and normally writes it to HISTFILE at exit or another configured time, so two sessions can temporarily differ.
Detailed explanation
Correct. The in-memory history and on-disk HISTFILE can be out of sync until a write occurs.
Incorrect. ~/.bash_history is normally a readable text file, not an executable.
Incorrect. Each Bash process has its own history list rather than one shared list.
Incorrect. The history file stores command lines, not only environment variables.
Try it yourself
An example you can run in a temporary verification environment.
bash -c 'printf "HISTFILE=%s\n" "${HISTFILE:-not-set-in-noninteractive-shell}"'Expected result
非対話シェルでは未設定の場合もあることを示す表示Key points
- Session history and the file differ
- The default HISTFILE is ~/.bash_history
- Write timing creates a delay
Notes
- Environment: Bash 5.x / 説明確認のみ
- Use disposable shell sessions and harmless commands for experiments.
- Shell behavior can depend on Bash options and distribution defaults.
Foundation review
Place the operation
A normal Bash session can write history at exit or on explicit commands, so memory and file contents can differ temporarily.
Check the side effect
Account for shell options and multiple sessions before assuming immediate cross-session synchronization.