summaryrefslogtreecommitdiffstats
path: root/src/m_mshrc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/m_mshrc.c')
-rw-r--r--src/m_mshrc.c20
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);
}