diff options
Diffstat (limited to 'xmake/plugins/lua')
| -rw-r--r-- | xmake/plugins/lua/xmake.lua | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/xmake/plugins/lua/xmake.lua b/xmake/plugins/lua/xmake.lua index bef62203b..269e1b944 100644 --- a/xmake/plugins/lua/xmake.lua +++ b/xmake/plugins/lua/xmake.lua @@ -34,8 +34,11 @@ task("lua") -- imports import("core.base.option") import("core.sandbox.sandbox") - import("core.project.history") - import("lib.readline") + local enable_readline = os.versioninfo().features.readline + if enable_readline then + import("core.project.history") + import("lib.readline") + end -- list all scripts? if option.get("list") then @@ -58,28 +61,33 @@ task("lua") import("scripts." .. name).main(unpack(option.get("arguments") or {})) end else - -- clear history - readline.clear_history() + local replhistory + if enable_readline then + -- clear history + readline.clear_history() - -- load history - local replhistory = history.load("replhistory") or {} - for _, ln in ipairs(replhistory) do - readline.add_history(ln) + -- load history + replhistory = history.load("replhistory") or {} + for _, ln in ipairs(replhistory) do + readline.add_history(ln) + end end -- enter interactive mode sandbox.interactive() - -- save to history - local entries = readline.get_history_state().entries - if #entries > #replhistory then - for i = #replhistory+1, #entries do - history.save("replhistory", entries[i].line) + if enable_readline then + -- save to history + local entries = readline.get_history_state().entries + if #entries > #replhistory then + for i = #replhistory+1, #entries do + history.save("replhistory", entries[i].line) + end end - end - -- clear history - readline.clear_history() + -- clear history + readline.clear_history() + end end end) |
