-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
53 lines (51 loc) · 1.13 KB
/
main.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
#include <stdio.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <string.h>
#include <stdlib.h>
#include <macros.h>
int main()
{
int status;
char ch[2]={"\n"};
getcwd(current_directory, sizeof(current_directory));
signal(SIGINT, sigintHandler);
while (1)
{
clear_variables();
prompt();
fgets(input_buffer, 1024, stdin);
if(strcmp(input_buffer, ch)==0)
{
continue;
}
if(input_buffer[0]!='!')
{
fileprocess();
filewrite();
}
len = strlen(input_buffer);
input_buffer[len-1]='\0';
strcpy(his_var, input_buffer);
if(strcmp(input_buffer, "exit") == 0)
{
flag = 1;
break;
}
if(input_buffer[0]=='!')
{
fileprocess();
bang_flag=1;
bang_execute();
}
with_pipe_execute();
waitpid(pid,&status,0);
}
if(flag==1)
{
printf("Bye...\n");
exit(0);
return 0;
}
return 0;
}