mirror of
https://github.com/KeyZox71/ft_minipowershell.git
synced 2025-03-15 11:26:51 +01:00
「🔨」 fix(builtins/export): fixed export double value problem
This commit is contained in:
@ -6,7 +6,7 @@
|
|||||||
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
|
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/06/26 08:42:36 by mmoussou #+# #+# */
|
/* Created: 2024/06/26 08:42:36 by mmoussou #+# #+# */
|
||||||
/* Updated: 2024/07/13 16:11:55 by mmoussou ### ########.fr */
|
/* Updated: 2024/07/14 13:52:32 by mmoussou ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
|
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/07/11 18:59:27 by mmoussou #+# #+# */
|
/* Created: 2024/07/11 18:59:27 by mmoussou #+# #+# */
|
||||||
/* Updated: 2024/07/13 16:10:28 by mmoussou ### ########.fr */
|
/* Updated: 2024/07/14 14:26:18 by mmoussou ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -20,7 +20,9 @@ void env_make_str(char *str, char *name, char *content)
|
|||||||
{
|
{
|
||||||
ft_strlcpy(str, name, ft_strlen(name) + 1);
|
ft_strlcpy(str, name, ft_strlen(name) + 1);
|
||||||
str[ft_strlen(name)] = '=';
|
str[ft_strlen(name)] = '=';
|
||||||
|
ft_strlcat(str, "\"", ft_strlen(str) + 2);
|
||||||
ft_strlcat(str, content, ft_vstrlen(2, str, content) + 1);
|
ft_strlcat(str, content, ft_vstrlen(2, str, content) + 1);
|
||||||
|
ft_strlcat(str, "\"", ft_strlen(str) + 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,7 +40,7 @@ char **env_get_list(t_env *env)
|
|||||||
{
|
{
|
||||||
if (ft_strcmp(env->name, "_"))
|
if (ft_strcmp(env->name, "_"))
|
||||||
{
|
{
|
||||||
ar[i] = ft_calloc(1, ft_vstrlen(2, env->name, env->content) + 2);
|
ar[i] = ft_calloc(1, ft_vstrlen(2, env->name, env->content) + 4);
|
||||||
if (!ar[i])
|
if (!ar[i])
|
||||||
{
|
{
|
||||||
ft_free("a", ar);
|
ft_free("a", ar);
|
||||||
@ -54,11 +56,12 @@ char **env_get_list(t_env *env)
|
|||||||
|
|
||||||
void add_to_env(char *name, char *content, t_env *env)
|
void add_to_env(char *name, char *content, t_env *env)
|
||||||
{
|
{
|
||||||
if (!content)
|
t_env *env_t;
|
||||||
content = ft_calloc(1, 1);
|
|
||||||
if (!content)
|
env_t = env;
|
||||||
return ;
|
while (env_t && ft_strcmp(env_t->name, name))
|
||||||
if (env_get_value(name, env))
|
env_t = env_t->next;
|
||||||
|
if (env_t)
|
||||||
env_edit(name, content, env);
|
env_edit(name, content, env);
|
||||||
else
|
else
|
||||||
ft_envadd_back(&env, ft_envnew(name, content));
|
ft_envadd_back(&env, ft_envnew(name, content));
|
||||||
|
5
src/env/env_setters.c
vendored
5
src/env/env_setters.c
vendored
@ -6,7 +6,7 @@
|
|||||||
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
|
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/05/22 14:42:52 by mmoussou #+# #+# */
|
/* Created: 2024/05/22 14:42:52 by mmoussou #+# #+# */
|
||||||
/* Updated: 2024/07/11 17:46:56 by mmoussou ### ########.fr */
|
/* Updated: 2024/07/14 13:59:13 by mmoussou ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -87,7 +87,10 @@ char **env_get(t_env *env)
|
|||||||
while (env)
|
while (env)
|
||||||
{
|
{
|
||||||
if (!env->content)
|
if (!env->content)
|
||||||
|
{
|
||||||
|
env = env->next;
|
||||||
continue ;
|
continue ;
|
||||||
|
}
|
||||||
ar[i] = ft_calloc(1, ft_vstrlen(2, env->name, env->content) + 2);
|
ar[i] = ft_calloc(1, ft_vstrlen(2, env->name, env->content) + 2);
|
||||||
if (!ar[i])
|
if (!ar[i])
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user