-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuiltins.c
More file actions
48 lines (41 loc) · 880 Bytes
/
Copy pathbuiltins.c
File metadata and controls
48 lines (41 loc) · 880 Bytes
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
#include "shell.h"
#include <stdlib.h>
/**
* exit_cmd - the function closes the shell when exit is typed.
* @arg: argument.
* @lineptre: standard input string
* @_exit: exiting value
*
* Description: This function is responsible for handling the "exit" command
* in the shell. If no argument is provided, it exits with the default exit
* value. Otherwise, it exits with the specified exit status.
*/
void exit_cmd(char **arg, char *lineptre, int _exit)
{
int _status = 0;
if (!arg[1])
{
free(lineptre);
free(arg);
exit(_exit);
}
_status = _atois(arg[1]);
free(lineptre);
free(arg);
exit(_status);
}
/**
*_getenv - gets the env variable.
*@env: env variable
*Return: 0
*/
void _getenv(char **env)
{
size_t env_v = 0;
while (env[env_v])
{
write(STDOUT_FILENO, env[env_v], _strlen(env[env_v]));
write(STDOUT_FILENO, "\n", 1);
env_v++;
}
}