Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
REPL: Load and write history to file #49
REPL: Load and write history to file #49
Changes from 3 commits
7cce09e
dc42914
a9c2c1d
6ede90e
b0bfa82
304d08d
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm running into some test errors around this code. This creates an empty file, which causes a confusing error from
::read_history()
:I did some experimentation, and this seems to be due to the file being empty, and not including the magic version header. If I start with
cp /dev/null ~/.hermes_history
I get the same warning.And if I C-d immediately, so that a file is written with no contents, then when I run the next time, I get a different confusing error:
What's the purpose of creating the empty file here? Can we suppress the empty write, so we don't get a warning?
Finally, I noticed the history file is mode 600, even though my umask is 0022. Shouldn't it be mode 644? Although I see other history files with the same mode, so maybe this is a readline "feature", it's not universal: node's history file is mode 644.
Sorry for all this. The libreadline history support seems unfortunately brittle.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sometimes it could happens when you don't have a
HOME
environment variable set. Besides that, I really don't know what could happens.The empty file is created in order to
write_history
to work, it opens the history file only on "append" mode, so if there is no file it returns aENOENT
error.The LLVM file system API should actually create a 666 mode, but 600 is actually a good choice because of security issues on accessing history files.
I'm reading the libreadline source code in order to understand it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, I'm avoiding creating empty files and ignoring
ENOENT
errors, because it happens in this case and that's an expected behavior.About the permission, actually there is nothing we could do about it (at least using libreadline), both version 7 and 8 set the file permission hardcoded.