-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcheckarg.c
More file actions
38 lines (34 loc) · 676 Bytes
/
checkarg.c
File metadata and controls
38 lines (34 loc) · 676 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
#include "simple_shell.h"
/**
* checkarg - analyzes the first argument passed to the program
* @argv: pointer to an array of strings representing command-line arguments
* Return: 0 if the main needs to be shut,
* 2 if the rest of the main needs to be skipped,
* 1 otherwise.
*/
int checkarg(char **argv)
{
if (argv == NULL)
{
printf("\nbye!\n");
return (0);
}
if (argv[0] == NULL)
return (2);
if (argv[0][0] != '/')
{
if (strcmp(*argv, "exit") == 0)
{
printf("Hope to see you soon!\n");
return (0);
}
else if (strcmp(*argv, "env") == 0)
{
pr_env();
return (2);
}
else
return (3);
}
return (1);
}