15
15
int exec_extern_cmd (char * * arguments );
16
16
int remove_folder (char * path );
17
17
18
- void handle_command (char * * arguments , int arg_count , char * * history , int * history_line , char * initial_directory ) {
18
+ void handle_command (char * command , char * * arguments , int arg_count , char * * history , int * history_line , char * initial_directory ) {
19
19
char buf [512 ];
20
20
if (strcmp (arguments [0 ], "pwd2" ) == 0 ) {
21
- add_cmd_his (arguments , history , history_line );
21
+ add_cmd_his (command , history , history_line );
22
22
if (getcwd (buf , sizeof (buf )) == NULL ) {
23
23
perror ("getcwd failed" );
24
24
log_error (arguments [0 ], "getcwd failed" );
@@ -28,13 +28,13 @@ void handle_command(char** arguments, int arg_count, char** history, int* histor
28
28
}
29
29
30
30
if (strcmp (arguments [0 ], "echo2" ) == 0 ) {
31
- add_cmd_his (arguments , history , history_line );
31
+ add_cmd_his (command , history , history_line );
32
32
printf ("%s\n" , arguments [1 ]);
33
33
return ;
34
34
}
35
35
36
36
if (strcmp (arguments [0 ], "cd2" ) == 0 ) {
37
- add_cmd_his (arguments , history , history_line );
37
+ add_cmd_his (command , history , history_line );
38
38
if (arg_count < 2 ) {
39
39
arguments [1 ] = initial_directory ;
40
40
}
@@ -49,7 +49,7 @@ void handle_command(char** arguments, int arg_count, char** history, int* histor
49
49
}
50
50
51
51
if (strcmp (arguments [0 ], "ls2" ) == 0 ) {
52
- add_cmd_his (arguments , history , history_line );
52
+ add_cmd_his (command , history , history_line );
53
53
if (arg_count < 2 ) {
54
54
arguments [1 ] = "." ;
55
55
}
@@ -75,7 +75,7 @@ void handle_command(char** arguments, int arg_count, char** history, int* histor
75
75
}
76
76
77
77
if (strcmp (arguments [0 ], "touch2" ) == 0 ) {
78
- add_cmd_his (arguments , history , history_line );
78
+ add_cmd_his (command , history , history_line );
79
79
if (arg_count < 2 ) {
80
80
arguments [1 ] = "filename" ;
81
81
}
@@ -91,7 +91,7 @@ void handle_command(char** arguments, int arg_count, char** history, int* histor
91
91
}
92
92
93
93
if (strcmp (arguments [0 ], "cat2" ) == 0 ) {
94
- add_cmd_his (arguments , history , history_line );
94
+ add_cmd_his (command , history , history_line );
95
95
if (arg_count < 2 ) {
96
96
perror ("not enough argument" );
97
97
log_error (arguments [0 ], "not enough argument" );
@@ -118,7 +118,7 @@ void handle_command(char** arguments, int arg_count, char** history, int* histor
118
118
}
119
119
120
120
if (strcmp (arguments [0 ], "cp2" ) == 0 ) {
121
- add_cmd_his (arguments , history , history_line );
121
+ add_cmd_his (command , history , history_line );
122
122
if (arg_count < 3 ) {
123
123
perror ("not enough argument" );
124
124
log_error (arguments [0 ], "not enough argument" );
@@ -158,7 +158,7 @@ void handle_command(char** arguments, int arg_count, char** history, int* histor
158
158
}
159
159
160
160
if (strcmp (arguments [0 ], "rename2" ) == 0 ) {
161
- add_cmd_his (arguments , history , history_line );
161
+ add_cmd_his (command , history , history_line );
162
162
if (arg_count < 3 ) {
163
163
perror ("not enough argument" );
164
164
log_error (arguments [0 ], "not enough argument" );
@@ -172,7 +172,7 @@ void handle_command(char** arguments, int arg_count, char** history, int* histor
172
172
}
173
173
174
174
if (strcmp (arguments [0 ], "rm2" ) == 0 ) {
175
- add_cmd_his (arguments , history , history_line );
175
+ add_cmd_his (command , history , history_line );
176
176
if (arg_count < 2 ) {
177
177
perror ("not enough argument" );
178
178
log_error (arguments [0 ], "not enough argument" );
@@ -201,7 +201,7 @@ void handle_command(char** arguments, int arg_count, char** history, int* histor
201
201
for (int i = 0 ; i < * history_line ; i ++ ) {
202
202
printf ("%s\n" , history [i ]);
203
203
}
204
- add_cmd_his (arguments , history , history_line );
204
+ add_cmd_his (command , history , history_line );
205
205
return ;
206
206
}
207
207
@@ -211,7 +211,7 @@ void handle_command(char** arguments, int arg_count, char** history, int* histor
211
211
printf ("Command not found or execution failed: %s\n" , arguments [0 ]);
212
212
log_error (arguments [0 ], "Command not found or execution failed" );
213
213
} else {
214
- add_cmd_his (arguments , history , history_line );
214
+ add_cmd_his (command , history , history_line );
215
215
}
216
216
}
217
217
0 commit comments