-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstate_utils.c
51 lines (42 loc) · 1.46 KB
/
state_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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* state_utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: bpisak-l <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/06/18 14:39:08 by bpisak-l #+# #+# */
/* Updated: 2024/07/29 10:48:58 by bpisak-l ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
void set_last_arg(char *arg)
{
t_state *s;
s = state();
free(s->last_arg);
s->last_arg = m_ft_strdup(arg);
}
void set_exit_code(int exit_code)
{
t_state *s;
s = state();
s->exit_code = exit_code;
}
void set_oldpwd(char *oldcwd)
{
char *path_copy;
path_copy = m_ft_strdup(oldcwd);
set_env_variable("OLDPWD", path_copy);
free(state()->oldcwd);
state()->oldcwd = path_copy;
}
void set_cwd(char *cwd)
{
char *path_copy;
path_copy = m_ft_strdup(cwd);
set_oldpwd(state()->cwd);
free(state()->cwd);
state()->cwd = path_copy;
set_env_variable("PWD", path_copy);
}