-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfeatures.c
More file actions
40 lines (36 loc) · 858 Bytes
/
Copy pathfeatures.c
File metadata and controls
40 lines (36 loc) · 858 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
#include "shell.h"
/**
* sh_env - Print the current environment variables
* @sh_ctx: pointer to the shell cotext struct
* Return: 0
*/
int sh_env(sh_context *sh_ctx)
{
print_list_str(sh_ctx->env_variables);
return (0);
}
/**
* get_features - Get some shell commands features
* @sh_ctx: pointer to the shell cotext struct
* Return: 0 on success,-1 if feature not found,
* 1 if found but wasn't successful,-2 if a feature signal exit()
*/
int get_features(sh_context *sh_ctx)
{
int i, value = -1;
feat_t feats[] = {
{"cd", sh_cd},
{"exit", sh_exit},
{"alias", sh_alias},
{"setenv", sh_setenv},
{"unsetenv", sh_rmenv},
{"env", sh_env},
{NULL, NULL}};
for (i = 0; feats[i].type; i++)
if (_strcmp(sh_ctx->cmd_args[0], feats[i].type) == 0)
{
sh_ctx->line_count++, value = feats[i].f(sh_ctx);
break;
}
return (value);
}