-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_execve1.c
More file actions
42 lines (39 loc) · 1.29 KB
/
run_execve1.c
File metadata and controls
42 lines (39 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* run_execve1.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adurusoy <adurusoy@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/20 22:14:35 by adurusoy #+# #+# */
/* Updated: 2023/12/20 22:14:36 by adurusoy ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
#include <stdlib.h>
char **get_args(t_parse *parse)
{
char **exec;
int i;
int j;
j = 0;
if (parse->text)
while (parse->text[j])
j++;
exec = malloc(sizeof(char *) * (j + 2));
if (!exec)
return (NULL);
i = 0;
exec[0] = ft_strdup(parse->cmd);
j = 1;
if (parse->text)
{
while (parse->text[i])
{
exec[j] = ft_strdup(parse->text[i++]);
j++;
}
}
exec[j] = NULL;
return (exec);
}