summaryrefslogtreecommitdiffstats
path: root/src/c_init.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/c_init.c')
-rw-r--r--src/c_init.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/c_init.c b/src/c_init.c
index 21f4a52..2ba73f5 100644
--- a/src/c_init.c
+++ b/src/c_init.c
@@ -29,6 +29,7 @@
#include "s_destroy.h"
#include "m_prompt.h"
#include "m_loop.h"
+#include "u_utils.h"
short
c_set_term_raw(char mode)
@@ -62,7 +63,7 @@ static void
if ((((tcaps->cpos) + tcaps->plen) %
tcaps->ws.ws_col) == 0)
{
- write(1, "\n\r", 2);
+ write(STDOUT_FILENO, "\n\r", 2);
return ;
}
c_redraw_line(*line, tcaps, msh);
@@ -71,6 +72,8 @@ static void
static short
c_read_cap(char *buf, char *line, t_caps *tcaps, t_msh *msh)
{
+ int tmp;
+
if (((*((unsigned int *)buf)) == LEFT_K) ||
((*((unsigned int *)buf)) == CTRL_B))
return (c_key_left(tcaps->plen, tcaps));
@@ -89,9 +92,13 @@ static short
line[0] == '\0')
{
c_set_term_raw(0);
- write(2, "exit\n", 5);
- exit(msh->ret);
- return (1);
+ write(STDERR_FILENO, "exit\n", 5);
+ u_eof_fd(msh->fd);
+ m_dump_hist(msh->curr_hist_ptr, msh);
+ tmp = msh->ret;
+ s_destroy(msh);
+ exit(tmp);
+ return (0);
}
else
return (0);