[RFC]: Patch to lua.c for saving command-line history

89 views
Skip to first unread message

Reuben Thomas

unread,
Jun 20, 2025, 7:28:29 AMJun 20
to lu...@googlegroups.com
Here's a patch I've long maintained for lua.c to save command-line history when lua.c is compiled with a suitable libreadline and libhistory.

I'm interested in comments about whether it would be welcome and useful in the default lua.c.

I last sent this patch to the list in 2007; I've maintained it since before then on the lua-users.org wiki.

I have continued to maintain and use this patch ever since, and it still works fine for me today. It's simple and short.

I wrote about some possible shortcomings in the list post in 2007, but I have not needed to address any of them since then. The most obvious one which might confuse or annoy users as it stands is that it saves the history in the current working directory, whereas REPLs typically save history in the user's home directory. This is easy to fix (set LUA_HISTORY in your environment, as I do, to ~/.lua_history), and avoids a lot of extra code to deal with finding the user's home directory, which lua.c doesn't currently do.

--
lua-5.4.8-save_readline_history.patch
Reply all
Reply to author
Forward
0 new messages