chiark / gitweb /
prefork-interp: wip args
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 17 Jul 2022 12:31:28 +0000 (13:31 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 21 Aug 2022 20:21:10 +0000 (21:21 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
cprogs/prefork-interp.c

index 29d39fe5e2ef8e7676713a04c7ae7c459821b621..de2b6f10154edb3385e3c4f35a60dae381763dab 100644 (file)
@@ -353,8 +353,34 @@ static int connect_or_spawn(void) {
   return fake_pair[0];
 }
 
-int main(int argc, const char *const *argv) {
-  script = process_opts(argc, argv);
+static void make_executor_argv(const char *const *argv) {
+  #define EACH_NEW_ARGV(EACH) {                        \
+    if ((arg = interp)) { EACH; }              \
+    if ((arg = script)) { EACH; }              \
+    const char *const *walk = argv;            \
+    while ((arg = *walk++)) { EACH; }          \
+  }
+
+  size_t count = 1;
+  MAKE_NEW_ARGV( count++ );
+
+  executor_argv = calloc(count, sizeof(char*));
+  if (!executor_argv) diee("allocate for arguments");
+
+  char **out = executor_argv;
+  MAKE_NEW_ARGV( *out++ = arg );
+  *out++ = 0;
+}  
+
+int main(int argc_unused, const char *const *argv) {
+  process_opts(&argv);
+
+  // Now we have
+  //  - possibly interp
+  //  - possibly script
+  //  - remaining args
+  // which ought to be passed on to the actual executor.
+  make_new_argv(argv);
 
   find_socket_path();
   FILLZERO(sun);