exit sur la sortie d'erreure et parsing des variables $ mieux

This commit is contained in:
Tom Moron
2024-02-12 20:12:39 +01:00
parent f63d26dea7
commit 979e4e54a0
21 changed files with 33154 additions and 51 deletions

16
ft_exec.c Normal file → Executable file
View File

@ -6,7 +6,7 @@
/* By: tomoron <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/07 14:12:49 by tomoron #+# #+# */
/* Updated: 2024/02/09 14:59:22 by tomoron ### ########.fr */
/* Updated: 2024/02/12 14:46:37 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
@ -14,14 +14,16 @@
int exec_builtin(t_cmd *parsed_cmd, t_env *env)
{
if (!strcmp(parsed_cmd->token, "echo"))
if (!ft_strcmp(parsed_cmd->token, "echo"))
g_return_code = ft_echo(parsed_cmd->next);
else if (!strcmp(parsed_cmd->token, "ret"))
else if (!ft_strcmp(parsed_cmd->token, "ret"))
g_return_code = ft_atoi(parsed_cmd->next->token);
else if (!strcmp(parsed_cmd->token, "env"))
else if (!ft_strcmp(parsed_cmd->token, "env"))
g_return_code = ft_print_env(env);
else if (!strcmp(parsed_cmd->token, "exit"))
else if (!ft_strcmp(parsed_cmd->token, "exit"))
ft_exit(parsed_cmd, env);
else if (!ft_strcmp(parsed_cmd->token, "pwd"))
g_return_code = ft_pwd();
else
return (STDIN_FILENO);
return (STDOUT_FILENO);
@ -29,9 +31,7 @@ int exec_builtin(t_cmd *parsed_cmd, t_env *env)
void ft_exec_command(t_cmd *parsed_cmd, t_env *env)
{
if (!parsed_cmd)
return ;
if (exec_builtin(parsed_cmd, env))
if (!parsed_cmd || exec_builtin(parsed_cmd, env))
return ;
ft_printf("not a builtin\n");
}