This commit is contained in:
Etienne Rey-bethbeder 2023-03-13 16:31:06 +01:00
commit 7ea602b12c
7 changed files with 15 additions and 19 deletions

View File

@ -95,7 +95,7 @@ static void ft_space_simplifier(char *str)
}
}
char *ft_formater(char *str)
char *ft_formater(t_data *data, const char *str)
{
char *out;
char *temp;
@ -112,5 +112,7 @@ char *ft_formater(char *str)
ft_space_simplifier(out);
if (out[ft_strlen(out) - 1] == ' ')
out[ft_strlen(out) - 1] = '\0';
return (out);
temp = ft_env_filler(data, out);
free(out);
return (temp);
}

View File

@ -1,6 +1,7 @@
#ifndef FORMAT_H
# define FORMAT_H
# include "../data/data.h"
char *ft_formater(char *str);
char *ft_formater(t_data *data, const char *str);
#endif

2
main.c
View File

@ -43,7 +43,7 @@ static int ft_minishell(t_data *data, char *line)
if (ft_syntax_verif(data, line))
return (0);
line_clean = ft_formater(line);
line_clean = ft_formater(data, line);
if (line_clean == NULL)
return (0);
if (ft_cmds_parser(data, line_clean))

View File

@ -1,9 +1,8 @@
#include "./parse_private.h"
int ft_args_parse(t_data *data, char *cmd_str, t_cmd *cmd)
static int ft_args_parse(char *cmd_str, t_cmd *cmd)
{
char **tab;
char *str;
size_t i;
tab = ft_split_quoted(cmd_str, ' ');
@ -12,22 +11,14 @@ int ft_args_parse(t_data *data, char *cmd_str, t_cmd *cmd)
i = 0;
while (tab[i] != NULL)
{
str = ft_env_filler(data, tab[i]);
if (str == NULL)
{
ft_freer_tab_ultimate(1, tab);
return (1);
}
ft_quote_remover(str);
free(tab[i]);
tab[i] = str;
ft_quote_remover(tab[i]);
i++;
}
cmd->args = tab;
return (0);
}
int ft_executable_parse(t_data *data, t_cmd *cmd)
static int ft_executable_parse(t_data *data, t_cmd *cmd)
{
bool own;
char *path;
@ -76,7 +67,7 @@ int ft_cmd_parser(t_data *data, char *cmd_str)
ft_cmddel(cmd);
return (1);
}
if (ft_args_parse(data, cmd_str, cmd))
if (ft_args_parse(cmd_str, cmd))
{
ft_cmddel(cmd);
return (1);
@ -100,6 +91,7 @@ int ft_cmds_parser(t_data *data, const char *line)
tab = ft_split_quoted(line, '|');
if (tab == NULL)
{
ft_freer_tab_ultimate(1, tab);
ft_eprintf("minishell: malloc failed\n");
return (1);
}

View File

@ -38,6 +38,8 @@ void ft_remove_redirection(char *cmd_str)
i++;
if (ft_is_in("<>", cmd_str[i]))
start = i;
if (start == -1)
continue ;
while (cmd_str[i] == cmd_str[start])
i++;
i++;

1
t
View File

@ -1 +0,0 @@
bozo

View File

@ -36,7 +36,7 @@ char *ft_quote_remover(char *str)
ft_strshift(str + stop - 1, -1);
start = -1;
stop = -1;
i = i - 2;
i = i - 1;
}
else
i++;