ferd / erlang-history

Hacks to add shell history to Erlang's shell
493 stars 30 forks source link

Handle history file access errors #14

Closed fhunleth closed 9 years ago

fhunleth commented 9 years ago

Admittedly my setup is special, since I'm running on embedded hardware where I have to handle some filesystems being corrupt or coming up read-only. When something happens to the place where the history file is stored, I lose access to the shell and get the unhelpful "ERROR: Shell process terminated!" error. This change just turns off the history feature if that happens, since that's way better than losing access to the shell completely. To test, point the history file to some place like "/root" or anywhere else that would give an eacces error.

Also, I only modified the 3.1 file since that's what I could test easily. FWIW, I tried to print a nice error message like you had, but ran into issues with the error message being printed twice despite trying to guard against that. It's clear that I don't quite understand the shell start sequence here. Without the nice error message, I do still get an error report with "permission denied" and the filename in the text, so that's better than nothing. Since this is such a corner case, I backed off and made the code as short as possible.

ferd commented 9 years ago

I'll be looking into this as soon as I get some time, thanks for the report.

fhunleth commented 9 years ago

No rush, and thanks for writing erlang-history. It is a huge improvement to my workflow.

ferd commented 9 years ago

I just pushed a full fix for all Erlang/OTP 17 versions (didn't bother with the old ones because nobody using these ever reported the issue): https://github.com/ferd/erlang-history/commit/56c58f6

Thanks for the report and initial work!

fhunleth commented 9 years ago

I just tried it out, and it works for me. Thanks!