fix: remove multiple redirection
This commit is contained in:
parent
96696243d0
commit
d56aac4b25
2
main.c
2
main.c
@ -44,7 +44,7 @@ static int ft_minishell(t_data *data, char *line)
|
|||||||
if (ft_syntax_verif(data, line))
|
if (ft_syntax_verif(data, line))
|
||||||
return (0);
|
return (0);
|
||||||
line_clean = ft_formater(data, line);
|
line_clean = ft_formater(data, line);
|
||||||
if (line_clean == NULL)
|
if (line_clean == NULL || line_clean[0] == '\0')
|
||||||
return (0);
|
return (0);
|
||||||
if (ft_cmds_parser(data, line_clean))
|
if (ft_cmds_parser(data, line_clean))
|
||||||
{
|
{
|
||||||
|
@ -98,17 +98,16 @@ int ft_cmds_parser(t_data *data, const char *line)
|
|||||||
i = 0;
|
i = 0;
|
||||||
while (tab[i] != NULL)
|
while (tab[i] != NULL)
|
||||||
{
|
{
|
||||||
if (ft_cmd_parser(data, tab[i]))
|
ft_cmd_parser(data, tab[i]);
|
||||||
{
|
|
||||||
ft_freer_tab_ultimate(1, tab);
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
if (*data->cmds != NULL)
|
||||||
|
{
|
||||||
if (((t_cmd *) (*data->cmds)->content)->fd_in[0] == -1)
|
if (((t_cmd *) (*data->cmds)->content)->fd_in[0] == -1)
|
||||||
((t_cmd *) (*data->cmds)->content)->fd_in[0] = 0;
|
((t_cmd *) (*data->cmds)->content)->fd_in[0] = 0;
|
||||||
if (((t_cmd *) (ft_lstlast(*data->cmds))->content)->fd_out[0] == -1)
|
if (((t_cmd *) (ft_lstlast(*data->cmds))->content)->fd_out[0] == -1)
|
||||||
(((t_cmd *) (ft_lstlast(*data->cmds))->content)->fd_out[0] = 1);
|
(((t_cmd *) (ft_lstlast(*data->cmds))->content)->fd_out[0] = 1);
|
||||||
|
}
|
||||||
ft_freer_tab_ultimate(1, tab);
|
ft_freer_tab_ultimate(1, tab);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
@ -42,12 +42,16 @@ void ft_remove_redirection(char *cmd_str)
|
|||||||
continue ;
|
continue ;
|
||||||
while (cmd_str[i] == cmd_str[start])
|
while (cmd_str[i] == cmd_str[start])
|
||||||
i++;
|
i++;
|
||||||
|
while (cmd_str[i] == ' ')
|
||||||
i++;
|
i++;
|
||||||
while (cmd_str[i] != '\0' && (cmd_str[i] != ' ' || ft_is_in_quote(cmd_str, i)))
|
while (cmd_str[i] != '\0' && (cmd_str[i] != ' ' || ft_is_in_quote(cmd_str, i)))
|
||||||
i++;
|
i++;
|
||||||
stop = i - start;
|
stop = i - start;
|
||||||
if (start != -1)
|
if (start != -1)
|
||||||
|
{
|
||||||
ft_strshift(cmd_str + start, -1 * stop);
|
ft_strshift(cmd_str + start, -1 * stop);
|
||||||
|
i = start;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user