Compare commits

..

No commits in common. "6ce54ea6fe0eceb1b68a2156acd12d63d6100f01" and "b1d827e106aea7b0b4fdb29469826e600d4334e2" have entirely different histories.

5 changed files with 18 additions and 12 deletions

View File

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

View File

@ -1,7 +1,6 @@
#ifndef FORMAT_H #ifndef FORMAT_H
# define FORMAT_H # define FORMAT_H
# include "../data/data.h"
char *ft_formater(t_data *data, const char *str); char *ft_formater(char *str);
#endif #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)) if (ft_syntax_verif(data, line))
return (0); return (0);
line_clean = ft_formater(data, line); line_clean = ft_formater(line);
if (line_clean == NULL) if (line_clean == NULL)
return (0); return (0);
if (ft_cmds_parser(data, line_clean)) if (ft_cmds_parser(data, line_clean))

View File

@ -1,8 +1,9 @@
#include "./parse_private.h" #include "./parse_private.h"
static int ft_args_parse(char *cmd_str, t_cmd *cmd) int ft_args_parse(t_data *data, char *cmd_str, t_cmd *cmd)
{ {
char **tab; char **tab;
char *str;
size_t i; size_t i;
tab = ft_split_quoted(cmd_str, ' '); tab = ft_split_quoted(cmd_str, ' ');
@ -11,14 +12,22 @@ static int ft_args_parse(char *cmd_str, t_cmd *cmd)
i = 0; i = 0;
while (tab[i] != NULL) while (tab[i] != NULL)
{ {
ft_quote_remover(tab[i]); 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;
i++; i++;
} }
cmd->args = tab; cmd->args = tab;
return (0); return (0);
} }
static int ft_executable_parse(t_data *data, t_cmd *cmd) int ft_executable_parse(t_data *data, t_cmd *cmd)
{ {
bool own; bool own;
char *path; char *path;
@ -67,7 +76,7 @@ int ft_cmd_parser(t_data *data, char *cmd_str)
ft_cmddel(cmd); ft_cmddel(cmd);
return (1); return (1);
} }
if (ft_args_parse(cmd_str, cmd)) if (ft_args_parse(data, cmd_str, cmd))
{ {
ft_cmddel(cmd); ft_cmddel(cmd);
return (1); return (1);

View File

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