CE Implement positional arguments
All checks were successful
Build ISO image / build-and-deploy (push) Successful in 36s
Build documentation / build-and-deploy (push) Successful in 1m23s

This commit is contained in:
2026-04-12 22:05:26 +02:00
parent 169fba6ee7
commit 9f216ffc49
4 changed files with 66 additions and 1 deletions

20
ce/ce.c
View File

@@ -8,6 +8,7 @@
#include <in_gb.h>
#include <in_input.h>
#include <malloc.h>
#include <minmax.h>
#include <mprintf.h>
#include <path.h>
#include <printf.h>
@@ -77,8 +78,23 @@ static bool split_lines_cb (void* ctx, const char* start, size_t len) {
return true;
}
static bool split_args_cb (void* ctx, const char* start, size_t len) {
(void)ctx;
if (posvar_count >= POSVAR_MAX)
return false;
struct posvar* posvar = &posvars[posvar_count++];
memset (posvar, 0, sizeof (*posvar));
memcpy (posvar->buf, start, min (len, sizeof (posvar->buf) - 1));
return true;
}
void app_main (void) {
char scriptpathbuf[PATH_MAX];
char posvarsbuf[2048];
char line[1024];
memset (scriptpathbuf, 0, sizeof (scriptpathbuf));
@@ -87,6 +103,10 @@ void app_main (void) {
if (has_script == ST_OK) {
interactive_mode = false;
if (env_get (process_get_pgid (), "args", (void*)posvarsbuf, sizeof (posvarsbuf)) == ST_OK) {
strtokenize (posvarsbuf, ' ', NULL, &split_args_cb);
}
char volume[VOLUME_MAX];
const char* path;
int ret;