]> Trent Huber's Code - thus.git/commitdiff
Bug fix for exec()
authorTrent Huber <trentmhuber@gmail.com>
Mon, 15 Jun 2026 02:11:25 +0000 (22:11 -0400)
committerTrent Huber <trentmhuber@gmail.com>
Mon, 15 Jun 2026 02:11:25 +0000 (22:11 -0400)
src/builtins/exec.c

index f05b9f432be4618f034ae987bde95cff94b2f7ea..52831bed3c922d1bbde4597438c2da6c30e41127 100644 (file)
@@ -21,8 +21,8 @@ int exec(char **args, size_t numargs) {
 
    if (numargs < 2) return usage(args[0], "command [args ...]");
 
-   clear(&c);
-   memcpy(c.tokens, args + 1, (c.numtokens = numargs - 1) * sizeof*args);
+   c = (struct context){.t = c.tokens, .numtokens = numargs - 1};
+   memcpy(c.tokens, args + 1, c.numtokens * sizeof*args);
    strcpy(c.name, args[1]);
    if (!(c.builtin = getbuiltin(c.name)) && !(c.path = getpath(c.name)))
        return note("Unable to find `%s' command", c.name);