summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/c_init.c15
-rw-r--r--src/e_unshebanged.c8
2 files changed, 15 insertions, 8 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);
diff --git a/src/e_unshebanged.c b/src/e_unshebanged.c
index fabba8a..49978a9 100644
--- a/src/e_unshebanged.c
+++ b/src/e_unshebanged.c
@@ -10,15 +10,15 @@
/* */
/* ************************************************************************** */
+#include <errno.h>
#include <libft.h>
-#include <stdlib.h>
-#include <unistd.h>
#ifdef __linux__
# include <linux/limits.h>
#else
# include <limits.h>
#endif
-#include <errno.h>
+#include <stdlib.h>
+#include <unistd.h>
#include "f_fail.h"
#include "s_struct.h"
@@ -30,8 +30,8 @@
static char **e_get_new_argv(const char fullpath[], t_com *ptr, t_msh *msh)
{
- char **argv;
size_t i;
+ char **argv;
if ((argv = (char**)malloc((3 +
u_builtins_get_argc((const char**)ptr->argv)) * sizeof(char*))) == NULL)