diff options
| author | Dominik Kaiser | 2024-10-21 15:08:10 +0200 |
|---|---|---|
| committer | Dominik Kaiser | 2024-10-21 15:08:10 +0200 |
| commit | b23715a8077cff0241b721889f17b3c3665d38f1 (patch) | |
| tree | 485ce333a1425b99a95f343996e6cd4fb58abdab /src/interpreter.c | |
| parent | 32e454ed265fc66dc45e43a3c68fbbe416fc16f9 (diff) | |
| download | minishell-b23715a8077cff0241b721889f17b3c3665d38f1.tar.gz minishell-b23715a8077cff0241b721889f17b3c3665d38f1.zip | |
Add basic command execution
Diffstat (limited to 'src/interpreter.c')
| -rw-r--r-- | src/interpreter.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/interpreter.c b/src/interpreter.c index 0fa7ac1..1082644 100644 --- a/src/interpreter.c +++ b/src/interpreter.c @@ -6,11 +6,12 @@ /* By: dkaiser <dkaiser@student.42heilbronn.de +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/08/05 13:15:24 by dkaiser #+# #+# */ -/* Updated: 2024/10/17 17:05:51 by dkaiser ### ########.fr */ +/* Updated: 2024/10/21 15:07:27 by dkaiser ### ########.fr */ /* */ /* ************************************************************************** */ #include "minishell.h" +#include <sys/wait.h> static int eval_pipe(t_pipe *pipe, t_env *env); static int eval_cmd(t_cmd *cmd, t_env *env); @@ -38,6 +39,13 @@ static int eval_pipe(t_pipe *pipe, t_env *env) static int eval_cmd(t_cmd *cmd, t_env *env) { - printf("%s\n", get_cmd_path(cmd->args[0], env)); + char *cmd_path; + + cmd_path = get_cmd_path(cmd->args[0], env); + if (cmd_path == NULL) + return (1); + free(cmd->args[0]); + cmd->args[0] = cmd_path; + execute_cmd(cmd, env); return (0); } |
