-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathft_history.c
69 lines (61 loc) · 2.02 KB
/
ft_history.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_history.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: djames <djames@student.hive.fi> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/05/10 18:13:24 by djames #+# #+# */
/* Updated: 2023/07/19 14:23:49 by djames ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
void ft_history(char *prom)
{
if (prom != NULL && (ft_strlen(prom) > 0))
add_history(prom);
}
void *print_errorexport(char *str, int flag)
{
int i;
i = ft_strlen(str);
if (flag == 0)
write(STDERR_FILENO, "MINISHELL: export: `", 20);
else if (flag == 1)
write(STDERR_FILENO, "MINISHELL: unset: `", 19);
write(STDERR_FILENO, str, i);
write(STDERR_FILENO, "': not a valid identifier\n", 26);
return (NULL);
}
void match_aux(int path_i, char **path_split, char *path_ptr, char *command)
{
ft_memcpy(path_ptr, *(path_split + path_i), ft_strlen(*(path_split
+ path_i)) + 1);
ft_memcpy(path_ptr + ft_strlen(path_ptr), "/", 2);
ft_memcpy(path_ptr + ft_strlen(path_ptr),
command, ft_strlen(command) + 1);
}
void start_env(char **str)
{
int i;
i = 0;
if (str[1] == NULL)
print_environment(1);
else
{
i = ft_strlen(str[1]);
write(STDERR_FILENO, "env: ", 5);
write(STDERR_FILENO, str[1], i);
write(STDERR_FILENO, ": No such file or directory\n", 28);
}
}
void aux_add25(int *i, int lenght, char **temp)
{
while (*i < (lenght))
{
temp[*i] = ft_strdup(g_data.envir[*i]);
if (!temp[*i])
exit(-1);
(*i)++;
}
}