-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhsh_help.c
executable file
·39 lines (36 loc) · 891 Bytes
/
hsh_help.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
#include <sys/wait.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include "string.h"
#include "holberton.h"
/**
* hsh_help - builtin command: print help.
* @a: List of args. Not examined.
* @p: the name of the executable program
* Return: Always returns 1, to continue executing.
*/
int hsh_help(char **a __attribute__((unused)), char *p __attribute__((unused)))
{
int i;
char *msg[] = {
"Holberton Student HSH\nThe following are built in:\n",
"You can use man for more infos.\n"
};
builtins bins[] = {
{"cd", hsh_cd},
{"help", hsh_help},
{"exit", hsh_exit},
{"env", hsh_env},
{"ls", hsh_ls},
{NULL, NULL}
};
write(STDOUT_FILENO, msg[0], _strlen(msg[0]));
for (i = 0; i < hsh_num_builtins(); i++)
{
write(STDOUT_FILENO, bins[i].builtin_str, _strlen(bins[i].builtin_str));
write(STDOUT_FILENO, "\n", 1);
}
write(STDOUT_FILENO, msg[1], _strlen(msg[1]));
return (1);
}