diff options
Diffstat (limited to 'cmd.c')
-rw-r--r-- | cmd.c | 22 |
1 files changed, 6 insertions, 16 deletions
@@ -30,23 +30,13 @@ void cmd(char *line) { return; } - /* If the command looks to be executable ... */ - if (access(cmd, X_OK) != -1) { - - /* ... fork and try to execute it; wait until the fork is done. */ - pid = fork(); - if (pid == 0) { - cmd_argv[0] = cmd; - execve(cmd, cmd_argv, environ); - } - waitpid(pid, &status, 0); - } - - /* Otherwise, print an error, because we couldn't find the command */ - else { - fprintf(stderr, "Command ā%sā not found\n", cmd); - return; + /* Fork and try to execute it; wait until the fork is done. */ + pid = fork(); + if (pid == 0) { + cmd_argv[0] = cmd; + execvp(cmd, cmd_argv); } + waitpid(pid, &status, 0); return; } |