summaryrefslogtreecommitdiffstats
path: root/src/ft_process_arg.c
blob: 9a1b620b5c5e58e8ad8df046fec839b9e0ee91ab (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
#include <libft.h>
#include <minishell.h>
#include <inttypes.h>

int
ft_process_arg(const char *arg)
{
	char **com;
	uint8_t i;

	if (arg[0] == '\0')
		return (0);
	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
		return (ft_error(com[0], 127));
	return (0);
}