summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-10-22 18:49:41 +0200
committerJozanLeClerc <bousset.rudy@gmail.com>2020-10-22 18:49:41 +0200
commitca88bc609950ebe3f84b4a5cadeb069fc3aded14 (patch)
tree38a9791a5acd7554bcceaaae86e0b9403b119d7d
parentIn progress (diff)
download42-minishell-ca88bc609950ebe3f84b4a5cadeb069fc3aded14.tar.gz
42-minishell-ca88bc609950ebe3f84b4a5cadeb069fc3aded14.tar.bz2
42-minishell-ca88bc609950ebe3f84b4a5cadeb069fc3aded14.tar.xz
42-minishell-ca88bc609950ebe3f84b4a5cadeb069fc3aded14.tar.zst
42-minishell-ca88bc609950ebe3f84b4a5cadeb069fc3aded14.zip
Unfinished
-rw-r--r--TODO.org1
-rw-r--r--src/e_redirs.c10
-rw-r--r--src/p_redirs.c3
-rw-r--r--src/s_lredir.c10
4 files changed, 15 insertions, 9 deletions
diff --git a/TODO.org b/TODO.org
index 596acda..893d935 100644
--- a/TODO.org
+++ b/TODO.org
@@ -48,6 +48,7 @@
** DONE Handle comments better #
** TODO Handle memory
** TODO Fix ~ only first pos of arg
+** TODO exit 25 leak is back
** TODO Various in-code TODO
* Stuff to add
diff --git a/src/e_redirs.c b/src/e_redirs.c
index 246f2c7..1d66226 100644
--- a/src/e_redirs.c
+++ b/src/e_redirs.c
@@ -83,21 +83,15 @@ void e_dup_redirs(const t_com *com, t_msh *msh)
while (ptr != NULL)
{
if (ptr->redir == -2 || ptr->redir == -3)
- {
e_redir_minus_two(ptr);
- }
else if (ptr->redir == -1)
- {
e_redir_minus_one(ptr, msh);
- }
else if (ptr->redir == 1)
- {
e_redir_plus_one(ptr, msh);
- }
else if (ptr->redir == 2)
- {
e_redir_plus_two(ptr, msh);
- }
+ /* else if (ptr->redir == 3) */
+ /* e_redir_plus_three(ptr, msh); */
ptr = ptr->next;
}
}
diff --git a/src/p_redirs.c b/src/p_redirs.c
index 6297255..108a2a3 100644
--- a/src/p_redirs.c
+++ b/src/p_redirs.c
@@ -44,6 +44,7 @@ static void p_append_redir(const char path[],
new = s_lredir_new(path, fd, redir);
if (new == NULL)
{
+ /* TODO: return (1) and abort command right here */
return ;
}
new->heredoc = NULL;
@@ -64,7 +65,7 @@ static size_t p_get_path(char path[],
size_t len;
hlen = 0;
- tmp.ptr += ft_abs(tmp.redir);
+ tmp.ptr += (tmp.redir == 3) ? (2) : (ft_abs(tmp.redir));
while (*tmp.ptr != C_NUL && ft_iswhitespace(*tmp.ptr) == TRUE)
tmp.ptr++;
if (*tmp.ptr == C_TILDE && u_get_var_value(h, "$HOME", PATH_MAX, msh) == 0)
diff --git a/src/s_lredir.c b/src/s_lredir.c
index 0457434..109f313 100644
--- a/src/s_lredir.c
+++ b/src/s_lredir.c
@@ -64,6 +64,14 @@ void s_lredir_clear(struct s_lredir **lredir)
*lredir = NULL;
}
+static int32_t s_get_right_fd(const char path[])
+{
+ int32_t rfd;
+
+ rfd = 0;
+ return (rfd);
+}
+
struct s_lredir *s_lredir_new(const char path[], int32_t fd, int8_t redir)
{
struct s_lredir *rdr;
@@ -72,6 +80,8 @@ struct s_lredir *s_lredir_new(const char path[], int32_t fd, int8_t redir)
return (NULL);
rdr->fd = fd;
rdr->right_fd = -1;
+ if (redir == 3 && rdr->right_fd = s_get_right_fd(path) == -1)
+ return (NULL);
rdr->redir = redir;
rdr->next = NULL;
ft_strlcpy(rdr->path, path, PATH_MAX);