Skip to content

Commit

Permalink
Pass env to builtins
Browse files Browse the repository at this point in the history
  • Loading branch information
davidar committed May 26, 2024
1 parent 6c335c2 commit 7d86a9f
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 7d86a9f

Please sign in to comment.