From 049446cc39cc41c7e154e651831b26c284c20226 Mon Sep 17 00:00:00 2001 From: Svetlana Panfilova Date: Thu, 8 May 2025 12:09:35 +0200 Subject: [PATCH] builtin functions in one file --- src/executer/execute_built_in.c | 35 ++++++++++++++++++++++++++++++++- src/executer/executer.c | 23 ++-------------------- 2 files changed, 36 insertions(+), 22 deletions(-) diff --git a/src/executer/execute_built_in.c b/src/executer/execute_built_in.c index 4911e7e..b36f730 100644 --- a/src/executer/execute_built_in.c +++ b/src/executer/execute_built_in.c @@ -1,5 +1,38 @@ +/* ************************************************************************** */ +/* */ +/* :::::::: */ +/* execute_built_in.c :+: :+: */ +/* +:+ */ +/* By: spanfilo +#+ */ +/* +#+ */ +/* 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) { if (ft_strncmp(command_args[0], "export", 7) == 0) @@ -16,4 +49,4 @@ void execute_builtin(char **command_args, t_minishell *mshell) exec_pwd(command_args, mshell); else if (ft_strncmp(command_args[0],"echo", 5) == 0) exec_echo(command_args, mshell); -} \ No newline at end of file +} diff --git a/src/executer/executer.c b/src/executer/executer.c index dc03580..8fff1ba 100644 --- a/src/executer/executer.c +++ b/src/executer/executer.c @@ -6,11 +6,11 @@ /* By: sveta +#+ */ /* +#+ */ /* Created: 2025/03/06 13:52:31 by sveta #+# #+# */ -/* Updated: 2025/05/06 16:49:25 by sveta ######## odam.nl */ -/* Updated: 2025/05/06 16:13:22 by jguacide ######## odam.nl */ +/* Updated: 2025/05/08 12:09:08 by spanfilo ######## odam.nl */ /* */ /* ************************************************************************** */ + #include "executer.h" int get_nbr_cmds(t_minishell *mshell) @@ -29,25 +29,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) { t_command *current;