summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-08-28 14:46:35 +0200
committerJozanLeClerc <bousset.rudy@gmail.com>2020-08-28 14:46:35 +0200
commit6f4b096ba1cff30c1c33dd887aa70740be7990c7 (patch)
tree893c469057e07bd64482af7d3055797dbea1703d /src
parentQuick tabs fix (diff)
download42-minishell-6f4b096ba1cff30c1c33dd887aa70740be7990c7.tar.gz
42-minishell-6f4b096ba1cff30c1c33dd887aa70740be7990c7.tar.bz2
42-minishell-6f4b096ba1cff30c1c33dd887aa70740be7990c7.tar.xz
42-minishell-6f4b096ba1cff30c1c33dd887aa70740be7990c7.tar.zst
42-minishell-6f4b096ba1cff30c1c33dd887aa70740be7990c7.zip
Multiline added for &&
Diffstat (limited to 'src')
-rw-r--r--src/m_loop.c5
-rw-r--r--src/m_loop_next.c29
-rw-r--r--src/m_loop_next.h5
3 files changed, 30 insertions, 9 deletions
diff --git a/src/m_loop.c b/src/m_loop.c
index a5e2723..1faa2cf 100644
--- a/src/m_loop.c
+++ b/src/m_loop.c
@@ -86,17 +86,14 @@ uint8_t
{
line = m_check_multi_backslash(fd, line, msh);
line = m_check_multi_pipe(fd, line, msh);
+ line = m_check_multi_and(fd, line, msh);
if (fd == STDIN_FILENO)
m_handle_hist(line, msh);
m_parse_and_run_line(line, msh);
/* TODO: (null): Bad address on "msh ~> echo a > asd; cat < asd" but not on "msh ~> echo a > asd; cat asd" */
- /* TODO: "msh ~> some command \": re GNL into ft_nrealloc */
- /* TODO: a histfile would be nice */
}
else
- {
ft_memdel((void*)&line);
- }
}
if (fd == STDIN_FILENO)
m_dump_hist(msh);
diff --git a/src/m_loop_next.c b/src/m_loop_next.c
index 9aa7129..1a8d867 100644
--- a/src/m_loop_next.c
+++ b/src/m_loop_next.c
@@ -60,7 +60,7 @@ static char
}
char
- *m_check_multi_backslash(int32_t fd, char *line, t_msh *msh)
+ *m_check_multi_backslash(int32_t fd, char line[], t_msh *msh)
{
if (line[ft_strlen(line) - 1] == '\\')
{
@@ -71,13 +71,13 @@ char
}
char
- *m_check_multi_pipe(int32_t fd, char *line, t_msh *msh)
+ *m_check_multi_pipe(int32_t fd, char line[], t_msh *msh)
{
char *pipe;
if ((pipe = ft_strrchr(line, '|')) != NULL)
{
- pipe++;
+ pipe += 1;
while (*pipe != '\0')
{
if (ft_isspace(*pipe) == FALSE)
@@ -93,3 +93,26 @@ char
return (line);
}
+char
+ *m_check_multi_and(int32_t fd, char line[], t_msh *msh)
+{
+ char *and;
+
+ if ((and = ft_strrchr(line, '&')) != NULL && *(and - 1) == '&')
+ {
+ and += 1;
+ while (*and != '\0')
+ {
+ if (ft_isspace(*and) == FALSE)
+ {
+ return (line);
+ }
+ and++;
+ }
+ line = m_counter_line_pipes(fd, 2, line, msh);
+ line = m_check_multi_backslash(fd, line, msh);
+ line = m_check_multi_pipe(fd, line, msh);
+ line = m_check_multi_and(fd, line, msh);
+ }
+ return (line);
+}
diff --git a/src/m_loop_next.h b/src/m_loop_next.h
index 56221e7..225e2ed 100644
--- a/src/m_loop_next.h
+++ b/src/m_loop_next.h
@@ -17,8 +17,9 @@
#include "s_struct.h"
-char *m_check_multi_backslash(int32_t fd, char *line, t_msh *msh);
-char *m_check_multi_pipe(int32_t fd, char *line, t_msh *msh);
+char *m_check_multi_backslash(int32_t fd, char line[], t_msh *msh);
+char *m_check_multi_pipe(int32_t fd, char line[], t_msh *msh);
+char *m_check_multi_and(int32_t fd, char line[], t_msh *msh);
#endif