-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshell_process.c
More file actions
43 lines (41 loc) · 835 Bytes
/
shell_process.c
File metadata and controls
43 lines (41 loc) · 835 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
41
42
43
#include "main.h"
/**
* sh - core of shell programe process
* @str: input string to shell
* @args: splitted string acc to breaks
* @paths: splitted path from environment
* @p_cnt: number of proccess
* @p_path: the program path
* @st: status of execution
* Return: status of execution
*/
void sh(char *str, char **args, char **paths, int p_cnt, char *p_path, int *st)
{
char *breaks = " ";
char *clean_string;
clean_string = cleanStr(str);
/*check \n && comment(#)*/
if (clean_string == NULL)
{
free(str);
*st = 0;
return;
}
args = split(str, breaks);
if (args[0] == NULL)
{
free_all(args, str, NULL);
*st = 0;
return;
}
if (check_exit(args, str, paths, st, p_path, p_cnt) != 0)
{
/* builtin checker */
*st = check_builtin(args);
if (*st == -1)
{
before_exec(args, paths, p_cnt, p_path, st);
}
}
free_all(args, str, NULL);
}