为什么我的 IRB 历史记录有时会丢失某些内容?
有时,我的 IRB 历史记录中会缺少某些内容。这种情况已经发生很多年了,但我并没有真正注意到其中的规律。我将使用 irb 一段时间,然后使用 control-d 退出它,几分钟后回来,我刚刚使用的命令不在那里,但当天或本周早些时候的命令却在那里。这主要/总是在 Rails 控制台中。
Sometimes things are missing from my irb history. This has been happening for years and I haven't really noticed a pattern. I'll use irb for a while, control-d out of it, come back in a few minutes later, and the commands I was just using aren't there, but commands from earlier in the day or week are there. This is mostly/always in a rails console.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我可能是错的,但阅读 http://trac.greenstone.org/browser/extensions/gsdl-video/trunk/installed/cmdline/lib/ruby/1.8/irb/ext/save-history.rb?rev=18425< /a>
让我觉得最后一个 irb 进程会用自己的进程覆盖其他进程的历史记录。
因此,如果您运行:
那么您的 .irb-history 应该保持不变,因为初始的后台 irb 将加载旧历史记录,然后在退出时覆盖新历史记录。
即:有点愚蠢:罪魁祸首是 open('w') 而不是 open('a') 。
如果这强烈激怒了您,您可以考虑编写一个补丁并为了更大的利益而提交它。
I could be wrong, but reading over http://trac.greenstone.org/browser/extensions/gsdl-video/trunk/installed/cmdline/lib/ruby/1.8/irb/ext/save-history.rb?rev=18425
makes me think that the last irb process will overwrite the other processes history with its own.
So if you run:
then your .irb-history should be unchanged, as the initial, backgrounded irb will have loaded the old history, then overwritten the new history as it exits.
ie: Somewhat foolishly: open('w') rather than open('a') is the culprit.
You might consider writing a patch and commiting it for the greater good if this strongly irritates you.