blob: f14270967422e8d980ef53e42d2ea44ec0917ffd (
plain)
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
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* export.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: charles <charles@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/01 17:11:34 by charles #+# #+# */
/* Updated: 2020/06/17 13:47:18 by nahaddac ### ########.fr */
/* */
/* ************************************************************************** */
/*
** \file export.c
** \brief `export` builtin
*/
// modify existing
// set with no string without '='
#include "minishell.h"
int builtin_export(char **argv)
{
char *temp;
size_t i;
if (argv[1] == NULL)
return (4);
if(isdigit(argv[1][0]))
return(0);
i = 0;
temp = argv[1];
while(temp[i] != '\0')
{
if(temp[i] == ' ' || isalnum(temp[i]) == 0)
return(2);
if (temp[i] == '=')
{
temp[i] = '\0';
env_export(env, temp, argv[1][i + 1]);
return(0);
}
i++;
}
return (3);
}
|