tb implement command logging

This commit is contained in:
2025-09-17 22:07:58 +02:00
parent ac1cc172f7
commit ba1c0eedbd
4 changed files with 14 additions and 5 deletions

View File

@ -20,7 +20,10 @@ uint64_t PID;
struct {
char *modestr;
enum { MODE_INTERACTIVE = 1, MODE_RUNFILE = 2 } mode;
char *filepath;
bool logcmds;
} CONFIG;
#define LINEBUF_MAX 1024
@ -28,6 +31,7 @@ struct {
static Arg ARGS[] = {
ARG("-m", ARG_STRING, &CONFIG.modestr),
ARG("-f", ARG_STRING, &CONFIG.filepath),
ARG("-logcmds", ARG_BOOL, &CONFIG.logcmds),
ARG_END(),
};
@ -79,7 +83,7 @@ void do_file(char *filepath) {
}
InterpResult *res;
bool ok = interp_runstring((const char *)buf, &res);
bool ok = interp_runstring((const char *)buf, &res, CONFIG.logcmds);
if (!ok) {
uprintf("Interpreter error:\n");
uprintf("%s\n", res->errmsg);
@ -109,7 +113,7 @@ void do_mode_interactive(void) {
linebuf[cursor - 1] = '\0';
uprintf("\n");
InterpResult *res;
if (!interp_runstring(linebuf, &res)) {
if (!interp_runstring(linebuf, &res, CONFIG.logcmds)) {
LOG(LOG_ERR, "%s\n", res->errmsg);
}
}