-
Notifications
You must be signed in to change notification settings - Fork 8
/
builtins_help_1.c
executable file
·101 lines (90 loc) · 3.38 KB
/
builtins_help_1.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
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
90
91
92
93
94
95
96
97
98
99
100
101
#include "shell.h"
void help_all(void);
void help_alias(void);
void help_cd(void);
void help_exit(void);
void help_help(void);
/**
* help_all - Displays all possible builtin shellby commands.
*/
void help_all(void)
{
char *msg = "Shellby\nThese shell commands are defined internally.\n";
write(STDOUT_FILENO, msg, _strlen(msg));
msg = "Type 'help' to see this list.\nType 'help name' to find ";
write(STDOUT_FILENO, msg, _strlen(msg));
msg = "out more about the function 'name'.\n\n alias \t";
write(STDOUT_FILENO, msg, _strlen(msg));
msg = "alias [NAME[='VALUE'] ...]\n cd \tcd ";
write(STDOUT_FILENO, msg, _strlen(msg));
msg = "[DIRECTORY]\n exit \texit [STATUS]\n env \tenv";
write(STDOUT_FILENO, msg, _strlen(msg));
msg = "\n setenv \tsetenv [VARIABLE] [VALUE]\n unsetenv\t";
write(STDOUT_FILENO, msg, _strlen(msg));
msg = "unsetenv [VARIABLE]\n";
write(STDOUT_FILENO, msg, _strlen(msg));
}
/**
* help_alias - Displays information on the shellby builtin command 'alias'.
*/
void help_alias(void)
{
char *msg = "alias: alias [NAME[='VALUE'] ...]\n\tHandles aliases.\n";
write(STDOUT_FILENO, msg, _strlen(msg));
msg = "\n\talias: Prints a list of all aliases, one per line, in ";
write(STDOUT_FILENO, msg, _strlen(msg));
msg = "the format NAME='VALUE'.\n\talias name [name2 ...]:prints";
write(STDOUT_FILENO, msg, _strlen(msg));
msg = " the aliases name, name2, etc. one per line, in the ";
write(STDOUT_FILENO, msg, _strlen(msg));
msg = "form NAME='VALUE'.\n\talias NAME='VALUE' [...]: Defines";
write(STDOUT_FILENO, msg, _strlen(msg));
msg = " an alias for each NAME whose VALUE is given. If NAME ";
write(STDOUT_FILENO, msg, _strlen(msg));
msg = "is already an alias, replace its value with VALUE.\n";
write(STDOUT_FILENO, msg, _strlen(msg));
}
/**
* help_cd - Displays information on the shellby builtin command 'cd'.
*/
void help_cd(void)
{
char *msg = "cd: cd [DIRECTORY]\n\tChanges the current directory of the";
write(STDOUT_FILENO, msg, _strlen(msg));
msg = " process to DIRECTORY.\n\n\tIf no argument is given, the ";
write(STDOUT_FILENO, msg, _strlen(msg));
msg = "command is interpreted as cd $HOME. If the argument '-' is";
write(STDOUT_FILENO, msg, _strlen(msg));
msg = " given, the command is interpreted as cd $OLDPWD.\n\n";
write(STDOUT_FILENO, msg, _strlen(msg));
msg = "\tThe environment variables PWD and OLDPWD are updated ";
write(STDOUT_FILENO, msg, _strlen(msg));
msg = "after a change of directory.\n";
write(STDOUT_FILENO, msg, _strlen(msg));
}
/**
* help_exit - Displays information on the shellby builtin command 'exit'.
*/
void help_exit(void)
{
char *msg = "exit: exit [STATUS]\n\tExits the shell.\n\n\tThe ";
write(STDOUT_FILENO, msg, _strlen(msg));
msg = "STATUS argument is the integer used to exit the shell.";
write(STDOUT_FILENO, msg, _strlen(msg));
msg = " If no argument is given, the command is interpreted as";
write(STDOUT_FILENO, msg, _strlen(msg));
msg = " exit 0.\n";
write(STDOUT_FILENO, msg, _strlen(msg));
}
/**
* help_help - Displays information on the shellby builtin command 'help'.
*/
void help_help(void)
{
char *msg = "help: help\n\tSee all possible Shellby builtin commands.\n";
write(STDOUT_FILENO, msg, _strlen(msg));
msg = "\n help [BUILTIN NAME]\n\tSee specific information on each ";
write(STDOUT_FILENO, msg, _strlen(msg));
msg = "builtin command.\n";
write(STDOUT_FILENO, msg, _strlen(msg));
}