」 feat(env_get_value): added a func to get value of a variable with the env struct

This commit is contained in:
yosyo
2024-05-27 13:13:46 +02:00
parent ad1f4e936d
commit 64f495b114
2 changed files with 21 additions and 2 deletions

11
src/env/env_cmd.c vendored
View File

@ -6,7 +6,7 @@
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/22 14:50:01 by mmoussou #+# #+# */
/* Updated: 2024/05/22 14:50:03 by mmoussou ### ########.fr */
/* Updated: 2024/05/27 13:11:07 by mmoussou ### ########.fr */
/* */
/* ************************************************************************** */
@ -65,6 +65,15 @@ int env_delete(char *name, t_env *env)
return (0);
}
char *env_get_value(char *name, t_env *env)
{
while (env && ft_strcmp(env->name, name))
env = env->next;
if (env)
return (env->content);
return (NULL);
}
void env_print(t_env *env)
{
while (env)