Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 34 additions & 1 deletion src/executer/execute_built_in.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,38 @@
/* ************************************************************************** */
/* */
/* :::::::: */
/* execute_built_in.c :+: :+: */
/* +:+ */
/* By: spanfilo <spanfilo@student.codam.nl> +#+ */
/* +#+ */
/* Created: 2025/05/08 11:51:23 by spanfilo #+# #+# */
/* Updated: 2025/05/08 11:56:35 by spanfilo ######## odam.nl */
/* */
/* ************************************************************************** */

#include "executer.h"

int is_builtin_cmd(char **command_args)
{
if (!command_args[0])
return(0);
if (ft_strncmp(command_args[0],"export", 7) == 0)
return (1);
if (ft_strncmp(command_args[0],"env", 4) == 0)
return (1);
if (ft_strncmp(command_args[0],"unset", 6) == 0)
return (1);
if (ft_strncmp(command_args[0],"exit", 5) == 0)
return (1);
if (ft_strncmp(command_args[0],"cd", 3) == 0)
return (1);
if (ft_strncmp(command_args[0],"echo", 5) == 0)
return (1);
if (ft_strncmp(command_args[0],"pwd", 4) == 0)
return (1);
return (0);
}

void execute_builtin(char **command_args, t_minishell *mshell, int *exit_status)
{
if (ft_strncmp(command_args[0], "export", 7) == 0)
Expand All @@ -16,4 +49,4 @@ void execute_builtin(char **command_args, t_minishell *mshell, int *exit_status)
exec_pwd(command_args, mshell);
else if (ft_strncmp(command_args[0],"echo", 5) == 0)
exec_echo(command_args, mshell);
}
}
19 changes: 1 addition & 18 deletions src/executer/executer.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
/* By: sveta <sveta@student.codam.nl> +#+ */
/* +#+ */
/* Created: 2025/03/06 13:52:31 by sveta #+# #+# */
/* Updated: 2025/05/08 12:09:08 by spanfilo ######## odam.nl */
/* Updated: 2025/05/07 20:40:17 by sveta ######## odam.nl */
/* */
/* ************************************************************************** */
Expand All @@ -29,24 +30,6 @@ int get_nbr_cmds(t_minishell *mshell)
return (nbr_cmds);
}

int is_builtin_cmd(char **command_args)
{
if (!command_args[0])
return(0);
if (ft_strncmp(command_args[0],"export", 7) == 0)
return (1);
if (ft_strncmp(command_args[0],"env", 4) == 0)
return (1);
if (ft_strncmp(command_args[0],"unset", 6) == 0)
return (1);
if (ft_strncmp(command_args[0],"exit", 5) == 0)
return (1);
if (ft_strncmp(command_args[0],"cd", 3) == 0)
return (1);
if (ft_strncmp(command_args[0],"echo", 5) == 0)
return (1);
return (0);
}

void execute_commands(t_minishell *mshell, int *exit_status)
{
Expand Down