aboutsummaryrefslogtreecommitdiff
path: root/src/eval/cmd.c
diff options
context:
space:
mode:
authorCharles Cabergs <me@cacharle.xyz>2020-09-14 20:48:50 +0200
committerCharles Cabergs <me@cacharle.xyz>2020-09-14 20:48:50 +0200
commit8e40323db9715621d8ab45ff6d943c2eeba46ea0 (patch)
tree010828d6a75dfaaf94535035dc50b6a2a55aa12e /src/eval/cmd.c
parent3693acaff9fbf3f34dc2907e95dd221d5a8bc9e4 (diff)
downloadminishell-8e40323db9715621d8ab45ff6d943c2eeba46ea0.tar.gz
minishell-8e40323db9715621d8ab45ff6d943c2eeba46ea0.tar.bz2
minishell-8e40323db9715621d8ab45ff6d943c2eeba46ea0.zip
Removing path hash table, replacing it by brute force searchpath
Diffstat (limited to 'src/eval/cmd.c')
-rw-r--r--src/eval/cmd.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/eval/cmd.c b/src/eval/cmd.c
index 455ff77..2f90378 100644
--- a/src/eval/cmd.c
+++ b/src/eval/cmd.c
@@ -6,7 +6,7 @@
/* By: charles <charles@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/06/14 10:41:31 by charles #+# #+# */
-/* Updated: 2020/09/14 17:18:05 by charles ### ########.fr */
+/* Updated: 2020/09/14 19:50:55 by charles ### ########.fr */
/* */
/* ************************************************************************** */
@@ -36,7 +36,7 @@ int wrapped_cmd(void *void_param)
}
}
-int eval_cmd(int fds[2], t_env env, t_path path, t_ast *ast, pid_t *child_pid)
+int eval_cmd(int fds[2], t_env env, t_ast *ast, pid_t *child_pid)
{
t_fork_param_cmd param;
char **argv;
@@ -54,13 +54,12 @@ int eval_cmd(int fds[2], t_env env, t_path path, t_ast *ast, pid_t *child_pid)
if (param.builtin == NULL)
{
- status = exec_search_path(path, env_search(env, "PATH"), argv[0], &param.exec_path);
- if (status != 0)
+
+ if (!path_search(env, argv[0], param.exec_path))
{
- if (status == 127)
- errorf("%s: command not found\n", argv[0]);
+ errorf("%s: command not found\n", argv[0]);
ft_split_destroy(argv);
- return (status);
+ return (127);
}
if ((status = exec_path_check(param.exec_path)) != 0)
return (status);