tb Enable/disable command logging dynamically + setlogcmds builtin

This commit is contained in:
2025-10-18 10:48:31 +02:00
parent d136c001df
commit a46da0a7ae
6 changed files with 56 additions and 21 deletions

View File

@ -3,6 +3,7 @@
#include <ulib.h>
#include "runtime.h"
#include "interp.h"
#include "config.h"
RtStringV *RTSTRINGV_STACK = NULL;
@ -242,7 +243,7 @@ bool rt_eachfile(Token *tks) {
InterpResult save; string_memcpy(&save, &RES, sizeof(save));
InterpResult *res;
interp_runstring(s, &res, false, false);
interp_runstring(s, &res, false);
string_memcpy(&RES, &save, sizeof(save));
/* ufree(s); */
@ -278,6 +279,28 @@ bool rt_mkaliasbn(Token *tks) {
return true;
}
bool rt_setlogcmds(Token *tks) {
Token *tk = tks;
if (tk == NULL) {
return false;
}
bool set;
if (string_strcmp(tk->str, "yes") == 0) {
set = true;
} else if (string_strcmp(tk->str, "no") == 0) {
set = false;
} else {
return false;
}
CONFIG.logcmds = set;
return true;
}
void rt_init(void) {
RTCMD("print", &rt_print);
RTCMD("mkalias", &rt_mkalias);
@ -287,4 +310,5 @@ void rt_init(void) {
RTCMD("stackpop", &rt_stackpop);
RTCMD("eachfile", &rt_eachfile);
RTCMD("mkaliasbn", &rt_mkaliasbn);
RTCMD("setlogcmds", &rt_setlogcmds);
}