diff options
| author | Charles <sircharlesaze@gmail.com> | 2020-06-14 16:07:19 +0200 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2020-06-14 16:07:19 +0200 |
| commit | 47fff4418d3a83ae214429f395232c3536ff03c4 (patch) | |
| tree | 8dd1021d3ae899b80cf052ae42a40c4bc965c654 /src/builtin | |
| parent | 26ddbd7146f65a2cf100713f422a9ab5b1890620 (diff) | |
| download | minishell-47fff4418d3a83ae214429f395232c3536ff03c4.tar.gz minishell-47fff4418d3a83ae214429f395232c3536ff03c4.tar.bz2 minishell-47fff4418d3a83ae214429f395232c3536ff03c4.zip | |
Added eval cmd and error handling draft, Updated preprocessing for list
Diffstat (limited to 'src/builtin')
| -rw-r--r-- | src/builtin/builtin.c | 38 |
1 files changed, 5 insertions, 33 deletions
diff --git a/src/builtin/builtin.c b/src/builtin/builtin.c index 65e8cf4..ae47a60 100644 --- a/src/builtin/builtin.c +++ b/src/builtin/builtin.c @@ -6,7 +6,7 @@ /* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/01 17:11:01 by charles #+# #+# */ -/* Updated: 2020/04/01 17:46:48 by charles ### ########.fr */ +/* Updated: 2020/06/14 12:52:12 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -31,44 +31,16 @@ static struct s_builtin_entry g_builtin_lookup[] = { {"exit", builtin_exit}, }; -/* -** \brief Call builtin function associated with command name -** \param argv Arguments to the builtin 'main', -** with argv[0] being the executable name -** \param env Environment Vector -** \return Builtin main return status -*/ - -int builtin_dispatch_run(char **argv, t_env env) -{ - size_t i; - - i = 0; - while (i < sizeof(g_builtin_lookup) / sizeof(struct s_builtin_entry)) - { - if (ft_strcmp(g_builtin_lookup[i].name, argv[0]) == 0) - return (g_builtin_lookup[i].func(argv, env)); - i++; - } - return (BUILTIN_NOT_FOUND); -} - -/* -** \brief Check if executable name is a builtin -** \param exec_name Executable name -** \return True if executable name is a builtin -*/ - -bool builtin_check_exec_name(char *exec_name) +t_builtin_func builtin_search_func(char *name) { size_t i; i = 0; while (i < sizeof(g_builtin_lookup) / sizeof(struct s_builtin_entry)) { - if (ft_strcmp(g_builtin_lookup[i].name, exec_name) == 0) - return (true); + if (ft_strcmp(g_builtin_lookup[i].name, name) == 0) + return (g_builtin_lookup[i].func); i++; } - return (false); + return (NULL); } |
