aboutsummaryrefslogtreecommitdiff
path: root/src/collect_redirs.c
diff options
context:
space:
mode:
authorDominik Kaiser2025-01-20 18:46:39 +0100
committerGitHub2025-01-20 18:46:39 +0100
commit9fa887da20e409c2f25fac44b57f999e508a30ea (patch)
tree7e3fee3edea18d0d81abddb89104858cfc0ec5e3 /src/collect_redirs.c
parentaf9d1a9b39daaf1b86cf94ee629e06503d8ab6d4 (diff)
parent62845ce01f222fad126372c574c7ab084478adf0 (diff)
downloadminishell-9fa887da20e409c2f25fac44b57f999e508a30ea.tar.gz
minishell-9fa887da20e409c2f25fac44b57f999e508a30ea.zip
Merge pull request #30 from dpu-kaiser/merge_format_redir
Merge format redir
Diffstat (limited to 'src/collect_redirs.c')
-rw-r--r--src/collect_redirs.c51
1 files changed, 27 insertions, 24 deletions
diff --git a/src/collect_redirs.c b/src/collect_redirs.c
index 350cf6b..837a16a 100644
--- a/src/collect_redirs.c
+++ b/src/collect_redirs.c
@@ -20,7 +20,8 @@ static t_redirection *set_redir(t_redirection *redir, int type, char *spec,
static int set_heredoc_data(t_token *cur, t_redirection *result,
t_env *env);
-t_redirection *collect_redirs(t_token **tokens, t_env *env, t_list **create_files)
+t_redirection *collect_redirs(t_token **tokens, t_env *env,
+ t_list **create_files)
{
t_redirection *result;
t_token *cur;
@@ -45,28 +46,6 @@ t_redirection *collect_redirs(t_token **tokens, t_env *env, t_list **create_file
return (result);
}
-static t_redirection *set_redir(t_redirection *redir, int type, char *spec,
- t_env *env)
-{
- t_redirection *result;
-
- redir->type = type;
- if (spec != NULL)
- redir->specifier = format_string(spec, env);
- else
- redir->specifier = spec;
- if (redir->type == OUTPUT_APPEND || redir->type == OUTPUT_OVERRIDE)
- {
- result = malloc(sizeof(t_redirection));
- if (!result)
- return (NULL);
- result->type = type;
- result->specifier = spec;
- return (result);
- }
- return (NULL);
-}
-
static void collect_and_check_redir(t_redirection *result, t_token **cur,
t_env *env, t_list **create_files)
{
@@ -89,7 +68,7 @@ static void collect_and_check_redir(t_redirection *result, t_token **cur,
ft_lstadd_back(create_files, ft_lstnew(set_redir(&result[1],
OUTPUT_APPEND, format_string(str, env), env)));
next_token = (*cur)->next;
- free_token_and_connect(*cur);
+ // free_token_and_connect(*cur);
if (next_token)
{
*cur = next_token->next;
@@ -99,6 +78,30 @@ static void collect_and_check_redir(t_redirection *result, t_token **cur,
*cur = NULL;
}
+static t_redirection *set_redir(t_redirection *redir, int type, char *spec,
+ t_env *env)
+{
+ t_redirection *result;
+
+ redir->type = type;
+ if (spec != NULL)
+ redir->specifier = format_string(spec, env, ft_atoi("0"));
+ else
+ redir->specifier = spec;
+ if (redir->type == OUTPUT_APPEND || redir->type == OUTPUT_OVERRIDE)
+ {
+ result = malloc(sizeof(t_redirection));
+ if (!result)
+ return (NULL);
+ result->type = type;
+ result->specifier = spec;
+ return (result);
+ }
+ return (NULL);
+}
+
+
+
static int set_heredoc_data(t_token *cur, t_redirection *result, t_env *env)
{
char *heredoc_data;