From 38572614766aed2a740b61700f403ee2955134ad Mon Sep 17 00:00:00 2001 From: Adam Joly Date: Tue, 9 Jul 2024 16:24:25 +0200 Subject: [PATCH] =?UTF-8?q?=E3=80=8C=F0=9F=94=A8=E3=80=8D=20fix:=20Fixed?= =?UTF-8?q?=20prompt=20and=20env?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/prompt.h | 6 +++--- src/main.c | 34 +++++++++++++++++++++++----------- src/prompt/get_prompt.c | 6 +++--- src/prompt/get_pwd.c | 8 ++++---- 4 files changed, 33 insertions(+), 21 deletions(-) diff --git a/include/prompt.h b/include/prompt.h index 57fabf9..4a82684 100644 --- a/include/prompt.h +++ b/include/prompt.h @@ -6,7 +6,7 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/05/19 13:48:05 by adjoly #+# #+# */ -/* Updated: 2024/05/27 18:59:56 by adjoly ### ########.fr */ +/* Updated: 2024/07/09 14:35:40 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ @@ -29,13 +29,13 @@ char *get_hostname(void); * * @return (char *) the pwd */ -char *get_pwd(t_env env); +char *get_pwd(t_env *env); /** * @brief return the full prompt * * @prompt (char *) the prompt */ -char *get_prompt(t_env env); +char *get_prompt(t_env *env); #endif diff --git a/src/main.c b/src/main.c index 2ac3b50..d9d299a 100644 --- a/src/main.c +++ b/src/main.c @@ -6,7 +6,7 @@ /* By: mmoussou +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/04/30 13:25:42 by adjoly #+# #+# */ -/* Updated: 2024/07/04 17:14:30 by adjoly ### ########.fr */ +/* Updated: 2024/07/09 14:35:13 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ @@ -14,11 +14,11 @@ #include "prompt.h" #include "env.h" -char *get_prompt(t_env env) +char *get_prompt(t_env *env) { char *prompt; - prompt = env_get_value("USER", &env); + prompt = env_get_value("USER", env); if (!prompt) prompt = ft_strdup("nixos"); prompt = ft_strjoin_free_s1(prompt, "@"); diff --git a/src/prompt/get_pwd.c b/src/prompt/get_pwd.c index 3f1a13d..381ab07 100644 --- a/src/prompt/get_pwd.c +++ b/src/prompt/get_pwd.c @@ -6,7 +6,7 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/05/02 14:42:00 by adjoly #+# #+# */ -/* Updated: 2024/07/04 17:14:14 by adjoly ### ########.fr */ +/* Updated: 2024/07/09 14:36:05 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ @@ -14,16 +14,16 @@ #include "libft.h" #include "env.h" -char *get_pwd(t_env env) +char *get_pwd(t_env *env) { char *pwd; char *home; char *tmp; - pwd = env_get_value("PWD", &env); + pwd = env_get_value("PWD", env); if (!pwd) return (NULL); - home = env_get_value("HOME", &env); + home = env_get_value("HOME", env); if (!home) return (NULL); if (!ft_strncmp(pwd, home, ft_strlen(home) - 1))