blob: 8057e42c8ab1b52b837aff32045faeb3e92c448b (
plain)
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
43
44
45
46
47
48
49
50
51
|
/* ************************************************************************** */
/* LE - / */
/* / */
/* ft_process_arg.c .:: .:/ . .:: */
/* +:+:+ +: +: +:+:+ */
/* By: rbousset <marvin@le-101.fr> +:+ +: +: +:+ */
/* #+# #+ #+ #+# */
/* Created: 2019/11/01 18:47:30 by rbousset #+# ## ## #+# */
/* Updated: 2019/11/01 18:47:32 by rbousset ### #+. /#+ ###.fr */
/* / */
/* / */
/* ************************************************************************** */
#include <libft.h>
#include <stdlib.h>
#include <minishell.h>
#include <inttypes.h>
int
ft_process_arg(char *arg)
{
char **com;
char *prev;
uint8_t i;
if (arg[0] == '\0')
return (0);
if (ft_strncmp(arg, "r", 1))
ft_history(arg);
i = 0;
com = ft_split(arg, ' ');
while (com[i])
i++;
if (!ft_strncmp(com[0], "exit", ft_strlen(com[0])))
return (ft_exit(com));
else if (!ft_strncmp(com[0], "echo", ft_strlen(com[0])))
return (ft_echo(com, i));
else if (!ft_strncmp(com[0], "pwd", ft_strlen(com[0])))
return (ft_pwd());
else if (!ft_strncmp(com[0], "r", 1))
{
prev = ft_get_last_line();
ft_putendl(prev);
ft_history("r");
ft_process_arg(prev);
free(prev);
}
else
return (ft_exec(com));
return (0);
}
|