From 7201a39ed9ccad3d08524d807e4f4ad49bbaec8a Mon Sep 17 00:00:00 2001 From: "Rob Swindell (on Debian Linux)" <rob@synchro.net> Date: Mon, 9 Dec 2024 18:16:47 -0800 Subject: [PATCH] Add RELOAD sysop command to reload a (JS) command shell without logoff/on We have to use load() (rather than js.exec) to invoke str_cmds.js so that an exit() will actually exit. Since load() automatically does the mods vs exec directory search-dance, that simplifies the code in default.js a little. I'm not sure exactly why I originally chose to use js.exec() over load() for invoking str_cmds.js, but for this feature, we need load() so let's go with that for now. I did encounter an issue (issue #840) while originally trying to make this work with the original code that called js.exec(), but just punted and went with load() instead. Perhaps if we fix issue #840, we can revert default.js back to using js.exec() (but why we would need/want to, I'm not sure). --- exec/default.js | 5 +---- exec/str_cmds.js | 5 +++++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/exec/default.js b/exec/default.js index f8e3c40172..32c7239c7e 100644 --- a/exec/default.js +++ b/exec/default.js @@ -203,10 +203,7 @@ while(bbs.online && !js.terminated) { cmd = console.getstr(); if(cmd == '!') cmd = last_str_cmd; - var script = system.mods_dir + "str_cmds.js"; - if(!file_exists(script)) - script = system.exec_dir + "str_cmds.js"; - js.exec(script, {}, cmd); + load({}, "str_cmds.js", cmd); last_str_cmd = cmd; continue; } diff --git a/exec/str_cmds.js b/exec/str_cmds.js index 47ecd91eeb..100257f92d 100644 --- a/exec/str_cmds.js +++ b/exec/str_cmds.js @@ -351,6 +351,11 @@ function str_cmds(str) return; } + if(str=="HELP") + writeln("RELOAD\tReload the current shell (if JavaScript)."); + if(str=="RELOAD") + exit(0); + if(str=="HELP") writeln("SLOG\tExecutes the slog utility to display system statistics."); if(str=="SLOG") { -- GitLab