-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhelp_info.c
More file actions
89 lines (79 loc) · 2.33 KB
/
help_info.c
File metadata and controls
89 lines (79 loc) · 2.33 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include "shs.h"
/**
* _help_info_env - Provides help information for the builtin env command.
* Return: No return value.
*/
void _help_info_env(void)
{
char *help = "env: env [option] [name=value] [command [args]]\n\t";
write(STDOUT_FILENO, help, _strlen(help));
help = "Print the environment of the shell.\n";
write(STDOUT_FILENO, help, _strlen(help));
}
/**
* _help_info_setenv - Provides help information
* for the builtin setenv command.
* Return: No return value.
*/
void _help_info_setenv(void)
{
char *help = "setenv: setenv (const char *name, const char *value, ";
write(STDOUT_FILENO, help, _strlen(help));
help = "int replace)\n\t";
help = "Add a new definition to the environment.\n";
write(STDOUT_FILENO, help, _strlen(help));
}
/**
* _help_info_unsetenv - Provides help information
* for the builtin unsetenv command.
* Return: No return value.
*/
void _help_info_unsetenv(void)
{
char *help = "unsetenv: unsetenv (const char *name)\n\t";
write(STDOUT_FILENO, help, _strlen(help));
help = "Remove an entry completely from the environment.\n";
write(STDOUT_FILENO, help, _strlen(help));
}
/**
* _help_info_exit - Provides help information for the builtin exit command.
* Return: No return value.
*/
void _help_info_exit(void)
{
char *help = "exit: exit [n]\n";
help = "Exit shell.\n";
write(STDOUT_FILENO, help, _strlen(help));
help = "Exits the shell with a status of N. If N is omitted, the exit ";
help = "status is that of the last command executed.\n";
write(STDOUT_FILENO, help, _strlen(help));
}
/**
* get_help - function that retrieves help messages according to the builtin
* @shdata: data structure (args and input)
* Return: 1
*/
int get_help(shell_data *shdata)
{
if (shdata->args[1] == NULL)
_help_info();
else if (_strcmp(shdata->args[1], "setenv") == 0)
_help_info_setenv();
else if (_strcmp(shdata->args[1], "env") == 0)
_help_info_env();
else if (_strcmp(shdata->args[1], "unsetenv") == 0)
_help_info_unsetenv();
else if (_strcmp(shdata->args[1], "help") == 0)
cmd_help();
else if (_strcmp(shdata->args[1], "exit") == 0)
_help_info_exit();
else if (_strcmp(shdata->args[1], "cd") == 0)
change_cd_help();
else if (_strcmp(shdata->args[1], "alias") == 0)
aux_help_alias();
else
write(STDERR_FILENO, shdata->args[0],
_strlen(shdata->args[0]));
shdata->status = 0;
return (1);
}