fix export a= ->a=""
This commit is contained in:
@ -6,7 +6,7 @@
|
|||||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/04/24 10:58:36 by marde-vr #+# #+# */
|
/* Created: 2024/04/24 10:58:36 by marde-vr #+# #+# */
|
||||||
/* Updated: 2024/04/26 10:26:03 by tomoron ### ########.fr */
|
/* Updated: 2024/05/03 14:25:03 by tomoron ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -19,7 +19,7 @@ t_env *dup_env(t_env *env)
|
|||||||
res = 0;
|
res = 0;
|
||||||
while (env)
|
while (env)
|
||||||
{
|
{
|
||||||
res = env_add_back(res, env->name, env->value);
|
res = env_add_back(res, env->name, env->value, 0);
|
||||||
env = env->next;
|
env = env->next;
|
||||||
}
|
}
|
||||||
return (res);
|
return (res);
|
||||||
@ -67,7 +67,7 @@ void print_env_declare(t_msh *msh, t_env *env_orig)
|
|||||||
{
|
{
|
||||||
if (strcmp(env->name, "_"))
|
if (strcmp(env->name, "_"))
|
||||||
{
|
{
|
||||||
if (env->value && *(env->value))
|
if (env->value)
|
||||||
ft_printf_fd(msh->out_fd, "declare -x %s=\"%s\"\n", env->name,
|
ft_printf_fd(msh->out_fd, "declare -x %s=\"%s\"\n", env->name,
|
||||||
env->value);
|
env->value);
|
||||||
else
|
else
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/02/18 18:29:20 by marde-vr #+# #+# */
|
/* Created: 2024/02/18 18:29:20 by marde-vr #+# #+# */
|
||||||
/* Updated: 2024/04/26 16:06:09 by tomoron ### ########.fr */
|
/* Updated: 2024/05/03 14:29:08 by tomoron ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -36,7 +36,7 @@ t_env *set_env(t_env *env, char *name, char *value, int flags)
|
|||||||
free(value);
|
free(value);
|
||||||
return (env);
|
return (env);
|
||||||
}
|
}
|
||||||
if (flags & 0b1)
|
if ((flags & 0b1) && tmp->value)
|
||||||
value = ft_strjoin_free(tmp->value, value, 2);
|
value = ft_strjoin_free(tmp->value, value, 2);
|
||||||
if (!value)
|
if (!value)
|
||||||
return (env);
|
return (env);
|
||||||
@ -46,7 +46,7 @@ t_env *set_env(t_env *env, char *name, char *value, int flags)
|
|||||||
}
|
}
|
||||||
tmp = tmp->next;
|
tmp = tmp->next;
|
||||||
}
|
}
|
||||||
return (env_add_back(env, name, value));
|
return (env_add_back(env, name, value, !(flags & 0b10)));
|
||||||
}
|
}
|
||||||
|
|
||||||
t_env *export_set_env(t_env *env, char *name, char *value, int flags)
|
t_env *export_set_env(t_env *env, char *name, char *value, int flags)
|
||||||
|
@ -6,21 +6,24 @@
|
|||||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/02/06 20:46:19 by tomoron #+# #+# */
|
/* Created: 2024/02/06 20:46:19 by tomoron #+# #+# */
|
||||||
/* Updated: 2024/04/29 22:11:22 by tomoron ### ########.fr */
|
/* Updated: 2024/05/03 14:20:04 by tomoron ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "minishell.h"
|
#include "minishell.h"
|
||||||
|
|
||||||
t_env *env_add_back(t_env *env, char *name, char *value)
|
t_env *env_add_back(t_env *env, char *name, char *value, int empty)
|
||||||
{
|
{
|
||||||
t_env *res;
|
t_env *res;
|
||||||
t_env *current;
|
t_env *current;
|
||||||
|
|
||||||
|
if(empty)
|
||||||
|
free(value);
|
||||||
res = ft_calloc(1, sizeof(t_env));
|
res = ft_calloc(1, sizeof(t_env));
|
||||||
if (!res)
|
if (!res)
|
||||||
return (env);
|
return (env);
|
||||||
res->name = name;
|
res->name = name;
|
||||||
|
if(!empty)
|
||||||
res->value = value;
|
res->value = value;
|
||||||
if (!env)
|
if (!env)
|
||||||
return (res);
|
return (res);
|
||||||
@ -35,7 +38,7 @@ int print_env(t_env *env)
|
|||||||
{
|
{
|
||||||
while (env)
|
while (env)
|
||||||
{
|
{
|
||||||
if (*env->value)
|
if (env->value)
|
||||||
ft_printf("%s=%s\n", env->name, env->value);
|
ft_printf("%s=%s\n", env->name, env->value);
|
||||||
env = env->next;
|
env = env->next;
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/02/02 21:59:20 by tomoron #+# #+# */
|
/* Created: 2024/02/02 21:59:20 by tomoron #+# #+# */
|
||||||
/* Updated: 2024/04/26 14:22:59 by tomoron ### ########.fr */
|
/* Updated: 2024/05/03 14:19:08 by tomoron ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ t_env *get_env(char **envp)
|
|||||||
j++;
|
j++;
|
||||||
name = ft_substr(*envp, 0, i);
|
name = ft_substr(*envp, 0, i);
|
||||||
value = ft_substr(*envp, i + 1, j);
|
value = ft_substr(*envp, i + 1, j);
|
||||||
env = env_add_back(env, name, value);
|
env = env_add_back(env, name, value, 0);
|
||||||
if (!name || !value)
|
if (!name || !value)
|
||||||
free_env(env);
|
free_env(env);
|
||||||
if (!name || !value)
|
if (!name || !value)
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/02/04 17:31:38 by tomoron #+# #+# */
|
/* Created: 2024/02/04 17:31:38 by tomoron #+# #+# */
|
||||||
/* Updated: 2024/04/30 14:00:33 by marde-vr ### ########.fr */
|
/* Updated: 2024/05/03 14:16:24 by tomoron ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -92,7 +92,7 @@ t_cmd *cmd_add_back(t_cmd *res, char *cmd, t_cmd_type type);
|
|||||||
void find_cmd_path(t_msh *msh, char **paths, int *found);
|
void find_cmd_path(t_msh *msh, char **paths, int *found);
|
||||||
void redirect_output(t_msh *msh, int i, char **cmd_args);
|
void redirect_output(t_msh *msh, int i, char **cmd_args);
|
||||||
void redirect_input(t_msh *msh, int i, char **cmd_args);
|
void redirect_input(t_msh *msh, int i, char **cmd_args);
|
||||||
t_env *env_add_back(t_env *env, char *name, char *value);
|
t_env *env_add_back(t_env *env, char *name, char *value, int empty);
|
||||||
void print_syntax_error_bonus(t_cmd *cmd, t_cmd *cmds);
|
void print_syntax_error_bonus(t_cmd *cmd, t_cmd *cmds);
|
||||||
int filename_corresponds(char *wildcard, char *value);
|
int filename_corresponds(char *wildcard, char *value);
|
||||||
void close_all_pipes(t_msh *msh, int cmd_count, int i);
|
void close_all_pipes(t_msh *msh, int cmd_count, int i);
|
||||||
|
Reference in New Issue
Block a user