-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshell.c
More file actions
39 lines (28 loc) · 695 Bytes
/
shell.c
File metadata and controls
39 lines (28 loc) · 695 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
#include "shell.h"
#include "prompt.h"
#include "utils.h"
#include "command_cd.h"
#include "command_pwd.h"
#include "command_echo.h"
#include "command_pinfo.h"
int main(void){
char* line_ptr = NULL;
size_t line_buffer_size = 0;
ssize_t line_size = 0;
init();
while(1){
free(line_ptr);
line_ptr = malloc(sizeof(char)*500);
line_buffer_size = 0;
line_size = 0;
prompt();
line_size = getline(&line_ptr, &line_buffer_size, stdin);
if (line_size <= 0){
free(line_ptr);
break;
}
line_ptr[strlen(line_ptr) - 1] = 0;
parse_input_string(line_ptr);
}
return 0;
}