add loop and builtins
This commit is contained in:
9
doc/code/builtins.txt
Normal file
9
doc/code/builtins.txt
Normal file
@@ -0,0 +1,9 @@
|
||||
void run_builtin(StringArray *args) {
|
||||
if (strcmp(args->array[0], "exit") == 0) {
|
||||
exit_shell(args);
|
||||
}
|
||||
}
|
||||
|
||||
void exit_shell(StringArray *args) {
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
@@ -13,10 +13,6 @@ void loop() {
|
||||
insert_string_array(&args, token);
|
||||
token = strtok_r(NULL, " ", &saveptr);
|
||||
}
|
||||
if (line != NULL) {
|
||||
free(line);
|
||||
line = NULL;
|
||||
}
|
||||
|
||||
if (args.size == 0) {
|
||||
continue;
|
||||
@@ -25,7 +21,5 @@ void loop() {
|
||||
if (is_builtin(args.array[0])) {
|
||||
run_builtin(&args);
|
||||
}
|
||||
|
||||
free_string_array(&args);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user