1
0
mirror of https://github.com/KeyZox71/ft_minipowershell.git synced 2025-05-13 16:08:45 +02:00

」 feat: Parsing of command kinda working

This commit is contained in:
2024-05-30 17:59:49 +02:00
parent d84749d009
commit 6bbdef9d7c
14 changed files with 248 additions and 33 deletions

View File

@ -6,7 +6,7 @@
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/24 11:18:04 by adjoly #+# #+# */
/* Updated: 2024/05/27 18:58:13 by adjoly ### ########.fr */
/* Updated: 2024/05/30 16:37:57 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
@ -21,6 +21,23 @@
#include "parsing.h"
#include "prompt.h"
void free_redir(void *redir_v)
{
t_redirection *redir;
redir = redir_v;
free(redir->file_name);
}
void free_token(void *token_v)
{
t_token *token;
token = token_v;
free(token->argv);
ft_lstclear(&(token->redirection), free_redir);
}
/*void print_cmd(t_cmd cmd)
{
ft_putendl_fd(cmd.cmd, 1);
@ -51,31 +68,38 @@ int main(int ac, char **av, char **env)
char **lll;
t_list *piped;
t_env env_l;
t_cmd *cmd;
//t_token *token;
(void)ac;
(void)av;
(void)env;
if (!env_init(env, &env_l))
{
}
piped = NULL;
if (env_init(env, &env_l))
return (EXIT_FAILURE);
while (1)
{
prompt = get_prompt(env_l);
test = readline(prompt);
free(prompt);
add_history(test);
check_syntax(test, av);
lll = ft_split(test, ' ');
if (!*lll)
continue ;
if (is_str(test, "exit"))
break;
piped = __split_pipe(test);
print_redir(__to_redir(piped->content));
//free(token);
break ;
piped = tokenizer(test);
// check_redir(((t_token *)(piped->content))->redirection, av);
/* while (piped)
{
print_token(piped->content);
piped = piped->next;
}*/
cmd = get_redir_fd(piped->content);
print_cmd(cmd);
free(test);
ft_lstclear(&piped, &free);
ft_lstclear(&piped, free_token);
ft_free("a", &lll);
}
ft_free("a", &lll);