tb Add & syntax to run commands without blocking/waiting

This commit is contained in:
2025-10-16 15:55:39 +02:00
parent e7421f73bb
commit 55f5fbefe4

View File

@ -188,6 +188,17 @@ bool interp_runstring(char *string, InterpResult **res, bool logcmds, bool inter
tz_classify(&tz); tz_classify(&tz);
tz_expandspecial(&tz); tz_expandspecial(&tz);
bool wait = true;
if (tz.tokens->str[0] == '&') {
Token *tk = tz.tokens;
LL_REMOVE(tz.tokens, tk);
ufree(tk->str);
ufree(tk);
wait = false;
}
Token *cmdtk = tz.tokens; Token *cmdtk = tz.tokens;
if (cmdtk->type == TOK_CMD) { if (cmdtk->type == TOK_CMD) {
ok = cmdtk->cmd(cmdtk->next); ok = cmdtk->cmd(cmdtk->next);
@ -217,6 +228,7 @@ bool interp_runstring(char *string, InterpResult **res, bool logcmds, bool inter
proc_run(app); proc_run(app);
if (wait) {
while(proc_pollstate(app) != 4) { while(proc_pollstate(app) != 4) {
if (interactive) { if (interactive) {
int32_t key = dev_cmd(&ps2kbdev, DEV_PS2KBDEV_READCH, (void *)PID, 0, NULL); int32_t key = dev_cmd(&ps2kbdev, DEV_PS2KBDEV_READCH, (void *)PID, 0, NULL);
@ -227,6 +239,7 @@ bool interp_runstring(char *string, InterpResult **res, bool logcmds, bool inter
} }
schedrelease(); schedrelease();
} }
}
cleanup: { cleanup: {
for (size_t j = 0; j < argslen1; j++) ufree(args1[j]); for (size_t j = 0; j < argslen1; j++) ufree(args1[j]);