nixpulvis / oursh

Your comrade through the perilous world of UNIX.
http://nixpulvis.com/oursh/oursh
MIT License
67 stars 6 forks source link

Save history on `exit` builtin #40

Closed nixpulvis closed 3 years ago

nixpulvis commented 6 years ago

In general we should have a common exit wrapper that performs cleanup/saving. This should also help address #36.

Here's where we save today:

https://github.com/nixpulvis/oursh/blob/835e83ede5fb087541a28e7eca9152d1f7bab1bb/src/repl/mod.rs#L205-L217

do-you-dare commented 6 years ago

What do you think about saving to history not only on exit, but on every (full) command call? That might make it easier to have a 'shared' history between your open shells, like with zsh.

Anyway, having a clean-up routine for exits, both intended and panicked, feels like a good idea :)

nixpulvis commented 6 years ago

@dread-uo I think #13 addresses your issues a bit more directly.

nixpulvis commented 6 years ago

This issue speaks to a design limitation atm were commands don't have access to any information from the repl, config, etc.

I'm working on adding config parameters in the initial-config branch, to each of the run calls. Though soon this will need to be something like Context or Runtime instead of just Config, to for example keep a reference to stdin/out, and own history in some way. Maybe with a Repl { stdin, stdout, history, ... }.

nixpulvis commented 3 years ago

Since Exit::run calls process::exit(n) directly, it doesn't have time to save history. I forgot this is still technically an issue then, but the impact is much lower now that things are saved on complete command now in #51.