forked from Muthami293/simple_shell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
builtins.c
47 lines (40 loc) · 753 Bytes
/
builtins.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
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/wait.h>
#include "shell.h"
/**
* handle_exit - handles exit command.
*
* @command: command passed to execute function.
* Return: 1 if the given command is exit, O otherwise.
*/
int handle_exit(char *command)
{
return (_strcmp(command, "exit") == 0);
}
/**
* handle_env - handles env command.
*
* @command: command passed to execute function.
* Return: 1 if the given command is env, O otherwise.
*/
int handle_env(char *command)
{
return (_strcmp(command, "env") == 0);
}
/**
* print_env - prints all environment variables.
*
* Return: void.
*/
void print_env(void)
{
char **env = environ;
while (*env)
{
_puts(*env);
env++;
}
}