diff options
author | 2021-05-04 02:40:10 +0200 | |
---|---|---|
committer | 2021-05-03 20:40:10 -0400 | |
commit | 25137717c9392d142650fcd679b09c400a2f5c4a (patch) | |
tree | 3d0f917bd4ef51a36cb45f78e3b8d33dcf375ffe /plugins/console/init.lua | |
parent | a90f1c885d8cbb7105cf6af2e1e2661799b5c529 (diff) |
Create console history file in homepath (#8026)
* Fix console history path, homepath is a core option
* Create missing directories recursively in lua plugins.
* Add lfs to global environment in a less magical way.
require normally doesn't bind the name globally just returns the
module, mame sets a preloader that does bind lfs globally, but
maybe it's less surprising to do it explicitly
Diffstat (limited to 'plugins/console/init.lua')
-rw-r--r-- | plugins/console/init.lua | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/plugins/console/init.lua b/plugins/console/init.lua index 95218d67389..c9811ba2467 100644 --- a/plugins/console/init.lua +++ b/plugins/console/init.lua @@ -13,6 +13,8 @@ local history_file = "console_history" local history_fullpath = nil +local util = require("util") + function console.startplugin() local conth = emu.thread() local ln_started = false @@ -239,8 +241,8 @@ function console.startplugin() end if (not started) then -- options are not available in startplugin, so we load the history here - local homepath = emu.subst_env(manager.ui.options.entries.homepath:value():match("([^;]+)")) - history_fullpath = homepath .. '/console_history' + local homepath = emu.subst_env(manager.options.entries.homepath:value():match("([^;]+)")) + history_fullpath = homepath .. '/' .. history_file ln.loadhistory(history_fullpath) started = true end @@ -298,7 +300,8 @@ end setmetatable(console, { __gc = function () if history_fullpath then - ln = require("linenoise") + util.create_parent_dirs(history_fullpath) + local ln = require("linenoise") ln.savehistory(history_fullpath) end end}) |