-
Notifications
You must be signed in to change notification settings - Fork 0
/
pipex_utils.c
executable file
·54 lines (47 loc) · 1.35 KB
/
pipex_utils.c
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
52
53
54
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* pipex_utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: zwalad <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/23 02:57:23 by zwalad #+# #+# */
/* Updated: 2022/08/25 02:31:10 by zwalad ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
void the_free(char **str)
{
int i;
i = 0;
while (str[i])
free(str[i++]);
free(str);
}
int herror(char *str)
{
perror(str);
exit(1);
return (0);
}
char *ft_access(char **str)
{
int i;
i = 0;
while (str[i])
{
if (access(str[i], F_OK) == -1)
i++;
if (access(str[i], F_OK) == 0)
return (str[i]);
}
free(str);
herror("no commands");
exit(1);
}
char *one_line(char *paths, char *str, char *sstr)
{
(void)paths;
free(str);
return (sstr);
}