diff --git a/bozo b/bozo new file mode 100644 index 0000000..e69de29 diff --git a/bozoman b/bozoman new file mode 100644 index 0000000..a609f77 --- /dev/null +++ b/bozoman @@ -0,0 +1,3 @@ +hi >> ./bozoman +hi >> ./bozoman +hi diff --git a/main.c b/main.c index 05ccd58..e4a965d 100644 --- a/main.c +++ b/main.c @@ -44,7 +44,7 @@ static int ft_minishell(t_data *data, char *line) if (ft_syntax_verif(data, line)) return (0); line_clean = ft_formater(data, line); - if (line_clean == NULL) + if (line_clean == NULL || line_clean[0] == '\0') return (0); if (ft_cmds_parser(data, line_clean)) { diff --git a/parse/parse.c b/parse/parse.c index 1c69a2c..ece8a33 100644 --- a/parse/parse.c +++ b/parse/parse.c @@ -98,17 +98,16 @@ int ft_cmds_parser(t_data *data, const char *line) i = 0; while (tab[i] != NULL) { - if (ft_cmd_parser(data, tab[i])) - { - ft_freer_tab_ultimate(1, tab); - return (1); - } + ft_cmd_parser(data, tab[i]); i++; } - if (((t_cmd *) (*data->cmds)->content)->fd_in[0] == -1) - ((t_cmd *) (*data->cmds)->content)->fd_in[0] = 0; - if (((t_cmd *) (ft_lstlast(*data->cmds))->content)->fd_out[0] == -1) - (((t_cmd *) (ft_lstlast(*data->cmds))->content)->fd_out[0] = 1); + if (*data->cmds != NULL) + { + if (((t_cmd *) (*data->cmds)->content)->fd_in[0] == -1) + ((t_cmd *) (*data->cmds)->content)->fd_in[0] = 0; + if (((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); return (0); } diff --git a/redirection/redirection.c b/redirection/redirection.c index 93855c2..3ff62b8 100644 --- a/redirection/redirection.c +++ b/redirection/redirection.c @@ -42,12 +42,16 @@ void ft_remove_redirection(char *cmd_str) continue ; while (cmd_str[i] == cmd_str[start]) i++; - i++; + while (cmd_str[i] == ' ') + i++; while (cmd_str[i] != '\0' && (cmd_str[i] != ' ' || ft_is_in_quote(cmd_str, i))) i++; stop = i - start; if (start != -1) + { ft_strshift(cmd_str + start, -1 * stop); + i = start; + } } }