diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-08-17 19:49:35 +0200 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-08-17 19:49:35 +0200 |
commit | 990143a3f21f5500abc329c7df4ef30d20cb71eb (patch) | |
tree | 4039744d012594f1923508bcb8f8c57c270e4172 /src/m_mshrc.c | |
parent | In progress (diff) | |
download | 42-minishell-990143a3f21f5500abc329c7df4ef30d20cb71eb.tar.gz 42-minishell-990143a3f21f5500abc329c7df4ef30d20cb71eb.tar.bz2 42-minishell-990143a3f21f5500abc329c7df4ef30d20cb71eb.tar.xz 42-minishell-990143a3f21f5500abc329c7df4ef30d20cb71eb.tar.zst 42-minishell-990143a3f21f5500abc329c7df4ef30d20cb71eb.zip |
.minishellrc working
Diffstat (limited to '')
-rw-r--r-- | src/m_mshrc.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/m_mshrc.c b/src/m_mshrc.c index acd64ec..f730113 100644 --- a/src/m_mshrc.c +++ b/src/m_mshrc.c @@ -11,15 +11,31 @@ /* ************************************************************************** */ #include <libft.h> +#include <stdint.h> #include <stdlib.h> #include <fcntl.h> #include <unistd.h> +#include "d_define.h" #include "s_struct.h" +#include "m_loop.h" #include "u_vars.h" -void +uint8_t m_source_mshrc(t_msh *msh) { - (void)msh; + int32_t fd; + char *home; + char file[2048]; + uint8_t ret; + + if ((home = u_get_var_value("$HOME", msh)) == NULL) + return (0); + 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); + close(fd); + return (ret); } |