CE Implement positional arguments
This commit is contained in:
20
ce/ce.c
20
ce/ce.c
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user