From 7d86a9f5df14e3814ed586ce66027b3403b0e31a Mon Sep 17 00:00:00 2001 From: David A Roberts Date: Sun, 26 May 2024 17:58:23 +1000 Subject: [PATCH] Pass env to builtins --- src/exec.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/exec.c b/src/exec.c index 6f4ee256..058969da 100644 --- a/src/exec.c +++ b/src/exec.c @@ -124,6 +124,17 @@ shellexec(char **argv, const char *path, int idx) envp = environment(); + for (int i = 0; envp[i]; i++) { + char name[strlen(envp[i])+1]; + strcpy(name, envp[i]); + char *eq = strchr(name, '='); + if (eq) { + *eq = '\0'; + if (strcmp(name, "PWD") == 0) continue; + setenv(name, eq+1, 1); + } + } + if (toy_find(argv[0])) { toy_exec(argv); }