-
-
Notifications
You must be signed in to change notification settings - Fork 627
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
Save history when the shell is exiting abnormally #2657
Labels
Comments
For reference,
|
Thanks for reporting @dratini0! I can confirm this behavior. |
Really? I thought that atexit was always run... |
This still is bugged fyi |
For others wishing to move to SQLite, use this once: How to convert history to sqlite? from xonsh.history.json import JsonHistory
from xonsh.history.sqlite import SqliteHistory
class History(SqliteHistory):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.clear()
jh = JsonHistory(**kwargs)
for item in jh.all_items():
self.append(item) |
anki-code
changed the title
History is not always saved when using the JSON backend
Save history when the shell is exiting abnormally
May 15, 2024
jnoortheen
pushed a commit
that referenced
this issue
May 16, 2024
) ### Before ```xsh echo 1 echo 2 # <<Crash>> # No json history ``` ### After Closes #2657 ```xsh echo 1 echo 2 # <<Crash>> # In json history # echo 1 # echo 2 ``` ## For community ⬇️ **Please click the 👍 reaction instead of leaving a `+1` or 👍 comment** --------- Co-authored-by: a <1@1.1>
gforsyth
pushed a commit
that referenced
this issue
May 22, 2024
### Motivation Development tools like PyCharm send SIGINT before SIGKILL in case of reload app. Saving history on SIGINT is the last chance to save history in this case. I understand that history will be flushed on Ctrl+C (SIGINT) but it looks like no bad consequences of this. In addition history saving will be more stable. ### Before ```xsh # Development in PyCharm xonsh --no-rc echo cmd # Ctrl+RR of Ctrl+DD to restart. # Command history lost. ``` ### After ```xsh # Development in PyCharm xonsh --no-rc echo cmd # Ctrl+R Ctrl+R for restart # Command history is here. ``` Closes #2657 ### Env Use `$XONSH_HISTORY_SIGINT_FLUSH=False` to switch it off. ## For community ⬇️ **Please click the 👍 reaction instead of leaving a `+1` or 👍 comment** --------- Co-authored-by: a <1@1.1> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When using the JSON backend, the history is not saved unless the shell is exited properly (for example, by ^D). When the
exec
alias is used, or a crash is induced (by for example adding invalid colors into$BOTTOM_TOOLBAR
), the history file is not saved, and is left locked without commands being written into it.My suspicion is that this is due to the fact that exit handlers are not ran when exec is used. This doesn't happen with SQLite for obvious reasons.
For community
⬇️ Please click the 👍 reaction instead of leaving a
+1
or 👍 commentThe text was updated successfully, but these errors were encountered: