/* By: ljiriste <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/07/21 21:24:52 by ljiriste #+# #+# */
-/* Updated: 2024/07/21 21:34:58 by ljiriste ### ########.fr */
+/* Updated: 2024/07/21 23:46:03 by ljiriste ### ########.fr */
/* */
/* ************************************************************************** */
void clean_env(t_execution_env *env)
{
clean_vars(env->vars);
+ free(env->vars);
ft_vec_free(&env->redirections, NULL);
return ;
}
/* By: ljiriste <ljiriste@student.42prague.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/07/21 08:57:54 by ljiriste #+# #+# */
-/* Updated: 2024/07/21 21:19:33 by ljiriste ### ########.fr */
+/* Updated: 2024/07/22 00:09:18 by ljiriste ### ########.fr */
/* */
/* ************************************************************************** */
while (i < vars->size)
{
line = ft_vec_caccess(vars, i);
- if (ft_strncmp(*line, var_name, len) && (*line)[len + 1] == '=')
- return (*line + len + 2);
+ if (!*line)
+ break ;
+ if (!ft_strncmp(*line, var_name, len) && (*line)[len] == '=')
+ return (*line + len + 1);
++i;
}
return (NULL);
return (0);
}
+static const char space = ' ';
+
int add_word(t_vec *exp_str, const char *word, const t_execution_env *env)
{
size_t i;
char *var;
const char *value;
+ i = 0;
while (word[i])
{
if (word[i] == '$')
if (ft_vec_append(exp_str, word + (i++)) != success)
return (1);
}
+ if (ft_vec_append(exp_str, &space) != success)
+ return (1);
return (0);
}
{
size_t i;
+ i = 0;
while (fields[i])
ft_printf("%s\n", fields[i++]);
return (0);
assignments_to_env(&assignments, env);
ft_vec_free(&redirections, NULL);
ft_vec_free(&assignments, NULL);
+ free_fields(fields);
return (0);
}
res = ex_fields(fields, &assignments, &redirections, env);