renamed functions to improve readability and removed useless test files
This commit is contained in:
37
exec.c
Executable file
37
exec.c
Executable file
@ -0,0 +1,37 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* exec.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/02/07 14:12:49 by tomoron #+# #+# */
|
||||
/* Updated: 2024/02/13 16:23:01 by marde-vr ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "minishell.h"
|
||||
|
||||
int exec_builtin(t_cmd *parsed_cmd, t_env *env)
|
||||
{
|
||||
if (!ft_strcmp(parsed_cmd->token, "echo"))
|
||||
g_return_code = echo(parsed_cmd->next);
|
||||
else if (!ft_strcmp(parsed_cmd->token, "ret"))
|
||||
g_return_code = ft_atoi(parsed_cmd->next->token);
|
||||
else if (!ft_strcmp(parsed_cmd->token, "env"))
|
||||
g_return_code = print_env(env);
|
||||
else if (!ft_strcmp(parsed_cmd->token, "exit"))
|
||||
ft_exit(parsed_cmd, env);
|
||||
else if (!ft_strcmp(parsed_cmd->token, "pwd"))
|
||||
g_return_code = pwd();
|
||||
else
|
||||
return (STDIN_FILENO);
|
||||
return (STDOUT_FILENO);
|
||||
}
|
||||
|
||||
void exec_command(t_cmd *parsed_cmd, t_env *env)
|
||||
{
|
||||
if (!parsed_cmd || exec_builtin(parsed_cmd, env))
|
||||
return ;
|
||||
ft_printf("not a builtin\n");
|
||||
}
|
Reference in New Issue
Block a user