summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjoe <rbousset@42lyon.fr>2020-11-25 17:24:14 +0100
committerjoe <rbousset@42lyon.fr>2020-11-25 17:24:14 +0100
commit4688255c3cb5570de3dffb10540ac4d686d3a6cb (patch)
tree2a93b30c3a0a7ef3ca5c1e38ef9e29bd4b0945e2
parentVery good fix (diff)
download42-minishell-4688255c3cb5570de3dffb10540ac4d686d3a6cb.tar.gz
42-minishell-4688255c3cb5570de3dffb10540ac4d686d3a6cb.tar.bz2
42-minishell-4688255c3cb5570de3dffb10540ac4d686d3a6cb.tar.xz
42-minishell-4688255c3cb5570de3dffb10540ac4d686d3a6cb.tar.zst
42-minishell-4688255c3cb5570de3dffb10540ac4d686d3a6cb.zip
goodax
-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)