fix env vide

This commit is contained in:
2024-03-25 13:30:55 +01:00
parent 1f567bd6ce
commit a140be4c3e
2 changed files with 9 additions and 6 deletions

View File

@ -6,7 +6,7 @@
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/02 21:59:20 by tomoron #+# #+# */
/* Updated: 2024/03/25 13:01:29 by marde-vr ### ########.fr */
/* Updated: 2024/03/25 13:19:26 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
@ -22,8 +22,11 @@ char *get_prompt(t_env *env)
res = ft_strjoin_free("\001", ft_get_color(10, 255, 80), 2);
res = ft_strjoin_free(res, "\033[1m\002", 1);
if(getenv("USER"))
{
res = ft_strjoin_free(res, getenv("USER"), 1);
res = ft_strjoin_free(res, "@", 1);
}
res = ft_strjoin_free(res, "minishell\001\033[0m\002:\001", 1);
res = ft_strjoin_free(res, ft_get_color(80, 80, 255), 3);
res = ft_strjoin_free(res, "\033[1m\002", 1);
@ -89,7 +92,7 @@ int main(int argc, char **argv, char **envp)
commands = (char *)1;
init_minishell(&msh, argc, argv, envp);
while (msh->env && commands)
while (commands)
{
prompt = get_prompt(msh->env);
if (!prompt)

View File

@ -6,7 +6,7 @@
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/21 21:47:15 by marde-vr #+# #+# */
/* Updated: 2024/03/23 19:24:52 by marde-vr ### ########.fr */
/* Updated: 2024/03/25 13:26:18 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
@ -20,7 +20,7 @@ char **split_paths_from_env(t_env *env)
path_in_envp = 0;
cur_env_var = env;
while (cur_env_var->next != 0)
while (cur_env_var && cur_env_var->next != 0)
{
if (!ft_strcmp(cur_env_var->name, "PATH"))
{