-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_cmds.c
51 lines (44 loc) · 1.42 KB
/
run_cmds.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* run_cmds.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: emohamed <emohamed@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/09/30 20:46:34 by haarab #+# #+# */
/* Updated: 2023/09/30 22:43:24 by emohamed ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
void run_export(t_vars *vars, int i)
{
int k;
if (!vars->cmds[i].cmds_args[1])
export_cmd(vars, NULL);
k = 1;
while (vars->cmds[i].cmds_args[k])
{
export_cmd(vars, vars->cmds[i].cmds_args[k]);
k++;
}
}
void run_unset(t_vars *vars, int i)
{
int k;
k = 1;
while (vars->cmds[i].cmds_args[k])
{
check_unset(vars->cmds[i].cmds_args, vars, k);
k++;
}
}
void run_exit(t_vars *vars, int i)
{
cmd_exit(vars->cmds[i].cmds_args);
exit(g_exit_status);
}
void run_pwd(char *cwd)
{
printf("%s\n", cwd);
g_exit_status = 0;
}