mirror of
https://github.com/KeyZox71/ft_minipowershell.git
synced 2025-03-15 03:16:51 +01:00
「🔨」 fix: fixed some things.
This commit is contained in:
@ -6,7 +6,7 @@
|
|||||||
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
|
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/04/25 12:20:26 by adjoly #+# #+# */
|
/* Created: 2024/04/25 12:20:26 by adjoly #+# #+# */
|
||||||
/* Updated: 2024/08/13 13:45:37 by adjoly ### ########.fr */
|
/* Updated: 2024/08/13 16:08:15 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -64,6 +64,7 @@ bool check_syntax(char *readline);
|
|||||||
bool check_redir(t_list *redir);
|
bool check_redir(t_list *redir);
|
||||||
bool check_argv(t_list *token);
|
bool check_argv(t_list *token);
|
||||||
bool check_wspace(char *readline);
|
bool check_wspace(char *readline);
|
||||||
|
bool check_redir_single(t_list *list);
|
||||||
/**
|
/**
|
||||||
* @brief Take the readline output and check if all the pipe
|
* @brief Take the readline output and check if all the pipe
|
||||||
* a command after them
|
* a command after them
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/07/09 16:32:21 by adjoly #+# #+# */
|
/* Created: 2024/07/09 16:32:21 by adjoly #+# #+# */
|
||||||
/* Updated: 2024/08/13 15:11:58 by adjoly ### ########.fr */
|
/* Updated: 2024/08/13 16:09:44 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -15,6 +15,22 @@
|
|||||||
#include "minishell.h"
|
#include "minishell.h"
|
||||||
|
|
||||||
bool check_redir(t_list *list)
|
bool check_redir(t_list *list)
|
||||||
|
{
|
||||||
|
t_list *tmp;
|
||||||
|
t_cmd *cmd;
|
||||||
|
|
||||||
|
tmp = list;
|
||||||
|
while (tmp)
|
||||||
|
{
|
||||||
|
cmd = (t_cmd *)tmp->content;
|
||||||
|
if (cmd->infile == -1 || cmd->outfile == -1)
|
||||||
|
return (send_error_parsing(ERROR_NO_FILE));
|
||||||
|
tmp = tmp->next;
|
||||||
|
}
|
||||||
|
return (false);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool check_redir_single(t_list *list)
|
||||||
{
|
{
|
||||||
t_list *tmp;
|
t_list *tmp;
|
||||||
t_redir *redir;
|
t_redir *redir;
|
||||||
@ -24,7 +40,7 @@ bool check_redir(t_list *list)
|
|||||||
{
|
{
|
||||||
redir = (t_redir *)tmp->content;
|
redir = (t_redir *)tmp->content;
|
||||||
if (redir->fd < 0 && redir->fd != -2)
|
if (redir->fd < 0 && redir->fd != -2)
|
||||||
return (send_error_parsing(ERROR_NO_FILE));
|
return (true);
|
||||||
tmp = tmp->next;
|
tmp = tmp->next;
|
||||||
}
|
}
|
||||||
return (false);
|
return (false);
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/08/05 14:19:35 by adjoly #+# #+# */
|
/* Created: 2024/08/05 14:19:35 by adjoly #+# #+# */
|
||||||
/* Updated: 2024/08/13 15:06:13 by adjoly ### ########.fr */
|
/* Updated: 2024/08/13 16:09:24 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -26,6 +26,8 @@ t_list *__get_redir(char **content)
|
|||||||
{
|
{
|
||||||
tmp = ft_lstnew(__open_heredoc(*(content + 1), list));
|
tmp = ft_lstnew(__open_heredoc(*(content + 1), list));
|
||||||
ft_lstadd_back(&list, tmp);
|
ft_lstadd_back(&list, tmp);
|
||||||
|
if (((t_redir *)tmp->content)->sign == ERROR)
|
||||||
|
return (list);
|
||||||
}
|
}
|
||||||
else if (sign != ERROR)
|
else if (sign != ERROR)
|
||||||
ft_lstadd_back(&list, ft_lstnew(__to_redir(*(content + 1), sign)));
|
ft_lstadd_back(&list, ft_lstnew(__to_redir(*(content + 1), sign)));
|
||||||
@ -41,6 +43,22 @@ void *clear_all_cmd(char **content, t_list *redir)
|
|||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
t_cmd *return_err_cmd(char **content, t_list *redir)
|
||||||
|
{
|
||||||
|
t_cmd *cmd;
|
||||||
|
|
||||||
|
cmd = ft_calloc(sizeof(t_cmd), 1);
|
||||||
|
if (!cmd)
|
||||||
|
return (clear_all_cmd(content, redir));
|
||||||
|
cmd->infile = -1;
|
||||||
|
cmd->outfile = -1;
|
||||||
|
cmd->cmd = NULL;
|
||||||
|
cmd->argv = NULL;
|
||||||
|
ft_free("a", &content);
|
||||||
|
ft_lstclear(&redir, free_redir);
|
||||||
|
return (cmd);
|
||||||
|
}
|
||||||
|
|
||||||
t_cmd *__to_cmd(char **content)
|
t_cmd *__to_cmd(char **content)
|
||||||
{
|
{
|
||||||
t_list *redir;
|
t_list *redir;
|
||||||
@ -56,8 +74,8 @@ t_cmd *__to_cmd(char **content)
|
|||||||
format_quotes(content);
|
format_quotes(content);
|
||||||
get_void(&content);
|
get_void(&content);
|
||||||
redir = __get_redir(content);
|
redir = __get_redir(content);
|
||||||
if (check_redir(redir))
|
if (check_redir_single(redir))
|
||||||
return (clear_all_cmd(content, redir));
|
return (return_err_cmd(content, redir));
|
||||||
cmd = ft_calloc(sizeof(t_cmd), 1);
|
cmd = ft_calloc(sizeof(t_cmd), 1);
|
||||||
if (!cmd)
|
if (!cmd)
|
||||||
return (clear_all_cmd(content, redir));
|
return (clear_all_cmd(content, redir));
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/05/18 20:13:50 by adjoly #+# #+# */
|
/* Created: 2024/05/18 20:13:50 by adjoly #+# #+# */
|
||||||
/* Updated: 2024/08/13 15:18:14 by adjoly ### ########.fr */
|
/* Updated: 2024/08/13 15:53:00 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -41,17 +41,20 @@ t_list *tokenizer(char *readline, t_env *env)
|
|||||||
ret = __to_cmd(split_argv(env_var_replace(tmp->content, env)));
|
ret = __to_cmd(split_argv(env_var_replace(tmp->content, env)));
|
||||||
if (!ret)
|
if (!ret)
|
||||||
return (clear_all(cmd, piped));
|
return (clear_all(cmd, piped));
|
||||||
|
if (((t_cmd *)ret)->infile == -2)
|
||||||
|
return (clear_all(cmd, piped));
|
||||||
ft_lstadd_back(&cmd, ft_lstnew(ret));
|
ft_lstadd_back(&cmd, ft_lstnew(ret));
|
||||||
if (!cmd)
|
if (!cmd)
|
||||||
return (clear_all(cmd, piped));
|
return (clear_all(cmd, piped));
|
||||||
if (((t_cmd *)ft_lstlast(cmd)->content)->infile == -2)
|
|
||||||
return (clear_all(cmd, piped));
|
|
||||||
//if (!ft_lstlast(cmd)->content)
|
|
||||||
//return (clear_all(cmd, piped));
|
|
||||||
if (!cmd->next)
|
if (!cmd->next)
|
||||||
get_list2(&cmd);
|
get_list2(&cmd);
|
||||||
tmp = tmp->next;
|
tmp = tmp->next;
|
||||||
}
|
}
|
||||||
ft_lstclear(&piped, free);
|
ft_lstclear(&piped, free);
|
||||||
|
if (check_redir(cmd))
|
||||||
|
{
|
||||||
|
ft_lstclear(&cmd, free_cmd);
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
return (cmd);
|
return (cmd);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user