Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

history should not behave like a "two-level store" #324

Open
andychu opened this issue May 31, 2019 · 0 comments
Open

history should not behave like a "two-level store" #324

andychu opened this issue May 31, 2019 · 0 comments

Comments

@andychu
Copy link
Contributor

andychu commented May 31, 2019

The thread over in #320 made me realize what is wrong with bash history. It has two parts:

  • the history in the current shell process
  • the persisted history in the ~/.bash_history file

When you exit a process, it appends to the history file shopt -s histappend

This is really confusing because most people use multiple shells at once! Exiting a shell shouldn't cause more lines to appear in the history of another shell!

This is the expected model for GNU readline, and OSH inherits it, but shouldn't.


It's not clear what the solution is, but ideas are:

  • History could be stored in a unique file keyed by (PID, timestamp). Then all of them would have to be searched for recent commands?) (History being stored in a separate file for each pwd ameliorates the problem, but doesn't solve it.)
  • try doing file system tricks for atomic writes (note that network file systems don't always obey POSIX)
  • use an sqlite database (don't want this to be a required dependency)

Probably the answer is to let the user register a history callback, something better than PROMPT_COMMAND. Then the plugins can do what they want, like use an sqlite database or whatever, or use separate files per directory, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant