From 8a1352d62c0dd66ecdd5807e83c16a00fb864635 Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Thu, 27 Aug 2020 17:47:04 +0200 Subject: Histfile is BAV --- src/m_init.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/m_init.c') diff --git a/src/m_init.c b/src/m_init.c index c145063..8b8a994 100644 --- a/src/m_init.c +++ b/src/m_init.c @@ -10,17 +10,27 @@ /* */ /* ************************************************************************** */ +#include #include #include "s_struct.h" +#include "u_vars.h" #include "u_vars_next.h" void m_init_custom_vars(t_msh *msh) { + char *home; + char fmt[255]; + u_subst_var_value("$PS1", FT_DEFAULT_PS_ONE, msh); u_subst_var_value("$PS2", FT_DEFAULT_PS_TWO, msh); u_subst_var_value("$PS3", FT_DEFAULT_PS_THR, msh); u_subst_var_value("$PS4", FT_DEFAULT_PS_FOU, msh); - u_subst_var_value("$HISTFILE", FT_DEFAULT_HISTFILE, msh); + if ((home = u_get_var_value("$HOME", msh)) != NULL) + { + ft_sprintf(fmt, "%s/%s", home, FT_DEFAULT_HISTFILE); + u_subst_var_value("$HISTFILE", fmt, msh); + ft_memdel((void*)&home); + } } -- cgit v1.2.3 From 4543c3ba3222d47780ad3e091cfe6f3098cc2bca Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Sun, 6 Sep 2020 21:56:20 +0200 Subject: Stacked --- src/m_init.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src/m_init.c') diff --git a/src/m_init.c b/src/m_init.c index 8b8a994..91baf7c 100644 --- a/src/m_init.c +++ b/src/m_init.c @@ -12,7 +12,9 @@ #include #include +#include +#include "d_define.h" #include "s_struct.h" #include "u_vars.h" #include "u_vars_next.h" @@ -20,17 +22,21 @@ void m_init_custom_vars(t_msh *msh) { - char *home; - char fmt[255]; + char home[PATH_MAX]; + char fmt[PATH_MAX]; u_subst_var_value("$PS1", FT_DEFAULT_PS_ONE, msh); u_subst_var_value("$PS2", FT_DEFAULT_PS_TWO, msh); u_subst_var_value("$PS3", FT_DEFAULT_PS_THR, msh); u_subst_var_value("$PS4", FT_DEFAULT_PS_FOU, msh); - if ((home = u_get_var_value("$HOME", msh)) != NULL) + u_get_var_value(home, "$HISTFILE", PATH_MAX, msh); + if (home[0] == C_NUL) { - ft_sprintf(fmt, "%s/%s", home, FT_DEFAULT_HISTFILE); - u_subst_var_value("$HISTFILE", fmt, msh); - ft_memdel((void*)&home); + u_get_var_value(home, "$HOME", PATH_MAX, msh); + if (home[0] != C_NUL) + { + ft_sprintf(fmt, "%s/%s", home, FT_DEFAULT_HISTFILE); + u_subst_var_value("$HISTFILE", fmt, msh); + } } } -- cgit v1.2.3