fix: redirection file == redirection sign
This commit is contained in:
parent
0bf045d4ab
commit
fdfe1c8b95
@ -6,7 +6,7 @@
|
|||||||
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
|
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/03/27 13:44:38 by cchauvet #+# #+# */
|
/* Created: 2023/03/27 13:44:38 by cchauvet #+# #+# */
|
||||||
/* Updated: 2023/03/29 19:31:35 by cchauvet ### ########.fr */
|
/* Updated: 2023/04/04 13:50:18 by alouis-j ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -83,7 +83,11 @@ int ft_cmd_parser(t_data *data, char *cmd_str)
|
|||||||
ft_eprintf("minishell: malloc failed\n");
|
ft_eprintf("minishell: malloc failed\n");
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
ft_redirection(data, cmd, cmd_str);
|
if (ft_redirection(data, cmd, cmd_str))
|
||||||
|
{
|
||||||
|
ft_cmddel(cmd);
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
if (ft_args_parse(cmd_str, cmd))
|
if (ft_args_parse(cmd_str, cmd))
|
||||||
{
|
{
|
||||||
ft_cmddel(cmd);
|
ft_cmddel(cmd);
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
|
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/03/29 17:32:06 by cchauvet #+# #+# */
|
/* Created: 2023/03/29 17:32:06 by cchauvet #+# #+# */
|
||||||
/* Updated: 2023/03/29 19:21:59 by cchauvet ### ########.fr */
|
/* Updated: 2023/04/04 13:40:29 by alouis-j ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -77,9 +77,26 @@ static bool ft_check_outfile_append(t_data *data, t_cmd *cmd,
|
|||||||
bool ft_check_redirection(t_data *data, t_cmd *cmd,
|
bool ft_check_redirection(t_data *data, t_cmd *cmd,
|
||||||
char *redirection_identifier, char *redirection)
|
char *redirection_identifier, char *redirection)
|
||||||
{
|
{
|
||||||
return (ft_check_heredoc(data, cmd, redirection_identifier, redirection)
|
char *str;
|
||||||
|| ft_check_infile(data, cmd, redirection_identifier, redirection)
|
bool return_code;
|
||||||
|| ft_check_outfile(data, cmd, redirection_identifier, redirection)
|
|
||||||
|| ft_check_outfile_append(data, cmd, redirection_identifier,
|
if (ft_is_in("<>", redirection[0]))
|
||||||
redirection));
|
{
|
||||||
|
ft_eprintf("minishell: %s: invalid redirection file\n", redirection);
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
str = ft_strdup(redirection);
|
||||||
|
if (str == NULL)
|
||||||
|
{
|
||||||
|
ft_eprintf("minishell: malloc failed\n");
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
ft_quote_remover(str);
|
||||||
|
return_code = (ft_check_heredoc(data, cmd, redirection_identifier, str)
|
||||||
|
|| ft_check_infile(data, cmd, redirection_identifier, str)
|
||||||
|
|| ft_check_outfile(data, cmd, redirection_identifier, str)
|
||||||
|
|| ft_check_outfile_append(data, cmd, redirection_identifier,
|
||||||
|
str));
|
||||||
|
free(str);
|
||||||
|
return (return_code);
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
|
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/03/27 13:44:22 by cchauvet #+# #+# */
|
/* Created: 2023/03/27 13:44:22 by cchauvet #+# #+# */
|
||||||
/* Updated: 2023/03/29 19:19:51 by cchauvet ### ########.fr */
|
/* Updated: 2023/04/04 13:52:55 by alouis-j ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -78,11 +78,15 @@ int ft_set_redirection(t_data *data, t_cmd *cmd, char **tab)
|
|||||||
i = 0;
|
i = 0;
|
||||||
while (tab[i + 1] != NULL)
|
while (tab[i + 1] != NULL)
|
||||||
{
|
{
|
||||||
ft_quote_remover(tab[i + 1]);
|
|
||||||
if (ft_check_redirection(data, cmd, tab[i], tab[i + 1]))
|
ft_check_redirection(data, cmd, tab[i], tab[i + 1]);
|
||||||
return (1);
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
if (ft_is_in("<>", tab[i][0]))
|
||||||
|
{
|
||||||
|
ft_eprintf("minishell: %s: must be followed by a file\n", tab[i]);
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user