diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-09-06 21:56:20 +0200 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-09-06 21:56:20 +0200 |
commit | 4543c3ba3222d47780ad3e091cfe6f3098cc2bca (patch) | |
tree | fb8a70bf05464a6fa2c820cc43ea34421340c903 /src/m_mshrc.c | |
parent | Commit from minishell (diff) | |
download | 42-minishell-4543c3ba3222d47780ad3e091cfe6f3098cc2bca.tar.gz 42-minishell-4543c3ba3222d47780ad3e091cfe6f3098cc2bca.tar.bz2 42-minishell-4543c3ba3222d47780ad3e091cfe6f3098cc2bca.tar.xz 42-minishell-4543c3ba3222d47780ad3e091cfe6f3098cc2bca.tar.zst 42-minishell-4543c3ba3222d47780ad3e091cfe6f3098cc2bca.zip |
Stacked
Diffstat (limited to '')
-rw-r--r-- | src/m_mshrc.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/m_mshrc.c b/src/m_mshrc.c index f730113..7f6b8b9 100644 --- a/src/m_mshrc.c +++ b/src/m_mshrc.c @@ -15,6 +15,7 @@ #include <stdlib.h> #include <fcntl.h> #include <unistd.h> +#include <limits.h> #include "d_define.h" #include "s_struct.h" @@ -24,15 +25,13 @@ uint8_t m_source_mshrc(t_msh *msh) { + char file[PATH_MAX]; + char home[PATH_MAX]; int32_t fd; - char *home; - char file[2048]; uint8_t ret; - if ((home = u_get_var_value("$HOME", msh)) == NULL) - return (0); + u_get_var_value(home, "$HOME", PATH_MAX, msh); ft_sprintf(file, "%s/%s", home, FT_MINISHELLRC); - ft_memdel((void*)&home); if ((fd = open(file, O_RDONLY)) < 0) return (0); ret = m_loop(fd, msh); |