diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2016-03-02 17:13:20 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2016-03-02 17:13:20 +1300 |
commit | 2a6a79d213b5940cb190f328d65a920d6be55cc9 (patch) | |
tree | 58365958f41e98103c7a6bba42e65bdb3b978041 /cmd.c | |
parent | Remove cuddled else (diff) | |
download | spsh-2a6a79d213b5940cb190f328d65a920d6be55cc9.tar.gz spsh-2a6a79d213b5940cb190f328d65a920d6be55cc9.zip |
Pass shell environment on to commands
Diffstat (limited to 'cmd.c')
-rw-r--r-- | cmd.c | 8 |
1 files changed, 2 insertions, 6 deletions
@@ -1,21 +1,17 @@ #include "spsh.h" /* Process a read line into a command and arguments and try to execute it */ -void cmd(char *line) { +void cmd(char *line, char **environ) { char *cmd, *cmd_arg; pid_t pid; int status, cmd_argc; char *cmd_argv[MAX_ARGS]; - char *cmd_envp[MAX_ENVS]; /* First argument is always the executable file itself; we make it NULL to * start with, and then terminate the array with NULL */ cmd_argv[0] = cmd_argv[1] = NULL; cmd_argc = 1; - /* Environment is just empty for now, I'll figure this out later */ - cmd_envp[0] = NULL; - /* Read the command as the first token of the line */ cmd = strtok(line, ARG_DELIM); @@ -41,7 +37,7 @@ void cmd(char *line) { pid = fork(); if (pid == 0) { cmd_argv[0] = cmd; - execve(cmd, cmd_argv, cmd_envp); + execve(cmd, cmd_argv, environ); } waitpid(pid, &status, 0); } |