From 398e4b5928bd2593a2f1df4c4bc59b6235c94b92 Mon Sep 17 00:00:00 2001 From: tomoron Date: Mon, 6 May 2024 13:19:17 +0200 Subject: [PATCH] fix too long path --- srcs/main.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/srcs/main.c b/srcs/main.c index 9389262..bfcc729 100755 --- a/srcs/main.c +++ b/srcs/main.c @@ -6,7 +6,7 @@ /* By: marde-vr +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/02/02 21:59:20 by tomoron #+# #+# */ -/* Updated: 2024/05/03 14:19:08 by tomoron ### ########.fr */ +/* Updated: 2024/05/06 13:14:50 by tomoron ### ########.fr */ /* */ /* ************************************************************************** */ @@ -31,13 +31,14 @@ char *get_prompt(t_env *env) res = ft_strjoin_free(res, ft_get_color(80, 80, 255), 3); res = ft_strjoin_free(res, "\033[1m\002", 1); cwd = getcwd(cwd_buffer, 99); - if (ft_get_env(env, "HOME") && !ft_strncmp(cwd_buffer, ft_get_env(env, - "HOME"), ft_strlen(ft_get_env(env, "HOME")))) + if (cwd && ft_get_env(env, "HOME") && !ft_strncmp(cwd_buffer, + ft_get_env(env,"HOME"), ft_strlen(ft_get_env(env, "HOME")))) { cwd += ft_strlen(getenv("HOME")) - 1; cwd[0] = '~'; } - res = ft_strjoin_free(res, cwd, 1); + if(cwd) + res = ft_strjoin_free(res, cwd, 1); res = ft_strjoin_free(res, "\001\033[0m\002$ ", 1); return (res); }