-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy patherror.c
58 lines (52 loc) · 1.75 KB
/
error.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* error.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: bmachado <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/12/09 12:56:36 by bmachado #+# #+# */
/* Updated: 2022/02/23 15:45:03 by bmachado ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
int error_msg(int type)
{
if (type == QUOTES || type == D_QUOTES)
printf("minishell: unclosed quotes\n");
else if (type == EQUAL)
printf("minishell: not found\n");
else if (type == PIPE)
printf ("minishell: parse error near \'|\'\n");
g_shell.error = 1;
return (-1);
}
static int exit_iden_error(void)
{
printf("minshell: \'=\' : not valid identifier\n");
g_shell.error = 1;
return (g_shell.error);
}
int invalid_assig(t_token **tk_lst, t_shell *table)
{
t_token *tk;
tk = *tk_lst;
while (tk)
{
if (tk->prev && !ft_strcmp(tk->prev->value, "export")
&& tk->type == DOLLAR && !expanded_var(tk->value, table))
{
if (tk->next && tk->next->type == EQUAL)
return (exit_iden_error());
}
tk = tk->next;
}
return (0);
}
void exit_process(t_shell *tab)
{
free_cmd_lst(g_shell.path);
free_cmd_lst(g_shell.env);
free_table(tab);
_exit(127);
}